Setting up CRON Jobs in Magento

Cron jobs, or scheduled tasks, must be enabled in order for Magento to operate properly. Because MageRewards 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 MageRewards 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 Suite

MageRewards 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.\

o run Test Suite, click on the  Run 'Test Suite' Diagnostics button.

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:

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

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:

2. Click on the  Cron Jobs icon.

3. Enter the following settings in the  Add New Cron Job section, replacing [magento_path] with the path to your Magento install:

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

Still need help? Get Help Get Help