Cron jobs stop working in Magento 1.8

A number of clients have experienced the same issue following upgrades to 1.8 from existing Magento installations – their Magento cron jobs, which historically had been operating just fine, stop working for no apparent reason.

Magento has two cron scrips, one a bash script ( and the other a PHP script (cron.php) – this issue was only happening with those clients who were running their cron jobs by calling the PHP script on a regular basis.

It turned out to be down to a code change in cron.php in Magento 1.8, which would try and use the bash script, in preference to the PHP script, if a shell was available, but in evaluating this was using a function which could give a false positive – making it think that a shell was available when it wasn’t. It would then try to use, but be unable to do so.

The solution is to tell the script that shell is disabled – in cron.php (which you’ll find in the web root of your installation) find the line :

$isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;

and immediately after it, add this :

$isShellDisabled = true;

This forces it to continue using the PHP script, rather than the shell script, irrespective of whether it thinks that it can use the shell or not. It’s a bit of a dirty hack, but it works!

Want to talk to us about your project?