How to Add cron.sh to Crontab When Cron is Not Working

croncrontab

I added this line to crontab on our server

*/5 * * * * /home/users/mydomain/www/cron.sh >> /home/users/mydomain/www/var/log/cron.log 2>&1

but Aoe_Scheduler said last cron success was few month ago

What should I do to make cron is working?

Best Answer

cron.sh by Magento has some issues. It spawns two processes, basically php cron.php -mdefault and php cron.php -malways, while STDERR is redirected to /dev/null (i.e. any error messages are swallowed).

So it is safer to set up the cron like this:

*/5 * * * * php /home/users/mydomain/www/cron.php -mdefault >> /home/users/mydomain/www/var/log/cron.log 2>&1
*/5 * * * * php /home/users/mydomain/www/cron.php -malways >> /home/users/mydomain/www/var/log/cron.log 2>&1

However, you said you have Aoe_Scheduler installed. This extension comes with a drop in replacement for cron.sh that enables additional features in the cron management like process monitoring. The file is scheduler_cron.sh and you find instructions how to set it up in the "Scheduler" menu of the Magento admin panel (assuming you have version 1.x, or at least 0.4 of the extension - if not, update, it's worth it!)

Related Topic