Cron Task Scheduler Issue – Last Heartbeat Older Than X Minutes

cron

We are using AOE cron scheduler from Fabrizio Branca. My scheduled tasks are loading, cron working fine etc. When I look at the timeline or list view, the jobs are loading successfully. But all of a sudden we are seeing the error message:

Last heartbeat is older than 37 minutes for example.

So the heartbeat scheduled task is not running at all currently. Any ideas how to begin debugging to try to work out the cause? I have looked at the log files which are giving no clues. I can manually run the task, but that is obviously not a solution. Any advice or ideas would be appreciated. Thanks.

Best Answer

This is probably one of the following two problems.

Your cron isn't being called properly

Often the cron.php just isn't called right. Either your cron.php isn't called at all or maybe it's called with insufficient rights or resources to execute properly. For example, executing the cron like this:

*/5 * * * * php -f /home/user/domain/public_html/cron.php

Might get very different results than expected because the user doesn't have the same rights as the user that runs the web server. And the PHP CLI has a different php.ini which may not have sufficiently large memory or execution time limits.

I often solve this by using wget or curl to call my cron or by editing the php.ini file that is used by my PHP CLI.

Magento is missing jobs

This happens if the settings under System > Configuration > System > Cron (Scheduled Tasks) are not configured corectly. This results in cron jobs being missed, even though the cron.php is called correctly. Make sure schedules are created and they schedule far enough ahead. And the "Missed if Not Run Within" is large enough.