OpenCart – How to Setup CRON

What is CRON?

WIKIPEDIA DEFINITION

Cron is the time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration, though its general-purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading email.[1] The name cron comes from the Greek word χρόνος [chronos] for time.

MY DEFINITION

Cron is a way to automate / execute scripts based on time intervals. It allows the user set up procedures that will fire according to the times set up on the Server. Typically, a URL is fired and that URL will execute a script that is located on the server (PUBLIC_LEVEL)

Setting up a CRON JOB

If you have an Arvixe hosting account then you will have already been inside your cPanel. Within the cPanel you can set up a CRON JOB very easily. Login to cPanel and scroll down to Advanced.

cron

Click on Cron Jobs

Now all you have to do is specify a time interval(s) for your new Cron Job.

cron2

Lastly, specify a COMMAND. This is important because without the command line being accurate the script will not fire. Your command line will be the PATH to the script and will typically look like this:

usr/bin/php -q /home/username/public_html/yourfilename.php

Note: With Cron you cannot access a file within the main core class of Opencart with Shell command. You have to access an isolated PHP file. Just use cURL to access a real URL inside the base class.

It might looks something like this:

<?php
if (file_exists(‘../../../config.php’)) {
require_once(‘../../../config.php’);
}
$ch = curl_init(HTTP_SERVER.”index.php?route=payment/recurringcallback”);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>

Notice the 3 ../../../ to locate the config file in your opencart install

You’ll also want to set permissions on the file to 755 to ensure it access it.

Looking for quality OpenCart Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , | Posted under OpenCart | RSS 2.0

Author Spotlight

Joe Stenhouse

Joe Stenhouse

I am a web application developer that specializes in PHP, JAVASCRIPT, MYSQL, HTML, and CSS. We manifest exciting potentials within the world wide web through means of innovation.

Leave a Reply

Your email address will not be published. Required fields are marked *


− 1 = 2

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>