How to Check If Cron is Working Fine with Magento?

Magento's cron entry point is the cron.php script in your Magento root. You'll need to setup an OS crontab entry hit this script like */5 * * * * www-data /usr/bin/php /var/www/magento/cron.php which you appear to have done already.Every time the cron.php script is hit three things happen like Schedule, Execute & Cleanup.If you want to test if your cron is actually working or not just you can simply write Mage::log('cron working', null, 'cron.log'); at the end of the cron.php file.

If the cron is working, it will create a cron.log file in your base dir.All cron related entry are stored into "cron_schedule" table.Often there can be failures with code or processes, timeouts, memory errors or issues with third-party modules causing the Cron system to block up.

Another way you can add below code at the end of the cron.php file.This updates a simple log called "cronlog.txt" everytime the cron.php file gets called.

try {
   $cronFile = "cronlog.txt";
   $fh = fopen($cronFile, 'w');
   $stringData = date('l jS \of F Y h:i:s A');
   fwrite($fh, $stringData);
   fclose($fh);
} catch (Exception $e) {
   Mage::printException($e);
}

If you face any problems or need our professional services, please email us at [email protected]

Join our Newsletter

Never miss the latest offers, voucher codes and useful articles delivered weekly in your inbox.