Magento cron.php not working

Sometimes on a Magento install the cron.php will not run as expected and various important automatic events do not occur.  In the latest version this even means that email are not sent.

Magento doesn’t have an easy, built in way to see whether things are working as they should be.  I use the free plugin, AOE Scheduler to see the status of cron triggered events.  When cron.php isn’t being run correctly you see an error message on the Schedule Configuration page saying

Last heartbeat is older than xx minutes

The first thing to check is that you do have a cron set up in you web server admin panel.

e.g. */5 * * * * username wget -O /dev/null -q http://www.example.com/cron.php

Obviously substitute the parts in orange for your own settings.  When this is set up it “should” work.  If you still don’t see a heartbeat task, keep going.

Another solution is in the cron.php file.  This involves editing a core file, so be aware that if you update your core Magento files the change may be overwritten.

In cron.php find:

$disabledFuncs = explode(',', ini_get('disable_functions'));
$isShellDisabled = is_array($disabledFuncs) ? in_array('shell_exec', $disabledFuncs) : true;
$isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;

Immediately after this add:

$isShellDisabled = true;

 

 

Share This