Setting up CRON Jobs in Magento

Cron jobs, or scheduled tasks, must be enabled in order for Magento to operate properly. Since Sweet Tooth is built upon Magento's functionality, it also inherits this requirement.

By default if you're running a UNIX operating system it should automatically recognize Magento's requests to use the CRON TAB service.

Magento needs Cron Jobs to be initiated for the following features to operate correctly:

  • Catalog Price rules
  • Sending Newsletters
  • Generating Google Sitemaps
  • Customer Alerts/Notifications (product price change, product back to stock)
  • Automatic updating of currency rates
  • Scheduled DB logs cleanup

Evidence of Magento not picking up CRON TAB tasks properly in Sweet Tooth is if the catalog redemption point rules block disappears one day after you applied all rules. If this is the case please consider the following content.

(For additional information on Cron Jobs in Magento,  check out the Magento Wiki article.)

Check to see if Cron is Running using Test Sweet

Sweet Tooth has built in diagnostic tools available that will let you know whether or not your Magento Cron is set up properly. To run this tool, navigate to Rewards > Configuration > Other Configuration and scroll down to  Diagnostics & Support Tools.\

Setting-up-cron-jobs-in-magento (1)To run Test Sweet, click on the  Run 'Test Sweet' Diagnostics button.

Setting-up-cron-jobs-in-magento (2)

Next you'll see several lines of diagnostics. Scroll down until you see  Magento - Cron.

If the Cron is setup and running properly, you'll see the following:

Setting-up-cron-jobs-in-magento (3)

If the Cron is not setup properly, Test Sweet will show you this warning:

Setting-up-cron-jobs-in-magento (4)

Follow the directions below to setup your cron.

Setting up the Cron In a UNIX Based Operating System

You can use the crontab service command if you have shell access to the server, or add it through your cPanel or similar admin. You need to make the script run every 5 minutes, so in advanced configurations you'd be entering in:

*/5 * * * *

The your crontab should have something like one of these:

*/5 * * * * /bin/sh /[magento_path]/ */5 * * * * /bin/bash /[magento_path]/ */5 * * * * /usr/bin/php /[magento_path]/cron.php */5 * * * * /usr/local/bin/php -f /[magento_path]/cron.php


Setting Up the Cron Using cPanel Version 11

If you're using cPanel 11, you can setup a Cron Job using the advanced tab.

1. Login to cPanel and locate the Advanced panel as shown here:

Setting-up-cron-jobs-in-magento (5)2. Click on the Cron Jobs icon.

Setting-up-cron-jobs-in-magento (6)3. Enter the following settings in the Add New Cron Job section, replacing [magento_path] with the path to your Magento install:

Setting-up-cron-jobs-in-magento (7)

4. Click Add New Cron Job to insert this cron job in the system.

Setting up a Scheduled Task In Windows

In windows you need to create a scheduled task that will execute the cron.php file every 5 minutes. To do this, go to the scheduled task manager and add a task to run the folllowing command:

php C:\[magento_path]\cron.php

Additional Testing to see if CRON is running

You can place some probes into and cron.php to confirm things are running.

You can add this to after the INSTALLDIR variable is set:

# absolute path to magento installation
INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'`
date >> "$0".log
whoami  >> "$0".log

And this to cron.php after the dispatchEvent call:

$log = fopen(__FILE__.'.log', 'a');
fwrite($log, date("Y-m-d H:i:s").PHP_EOL);

After 6 minutes you should see both these files in Magento's directory if cron is running.


If you have tried everything and still cant get cron to work, perhaps this unsupported workaround might help. Adding the following to the top of index.php will cause cron to run in the background whenever someone accesses your website.

$pathToCron = dirname(__FILE__)."/";
exec( "sh $pathToCron > /dev/null &" );

Another workaround

*/5 * * * * /usr/bin/wget