3

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?

1

1 Answer 1

2

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!)

5
  • it may be better to stick with cron.sh as it checks if cron is already running and doesn't run new cron in such case. In other case you may end up in multiple cron instance running at the same time. Aug 19, 2015 at 19:43
  • 1
    another thing that is handled better by Aoe_Scheduler. But you are right, that's an argument against running cron.php directly, at least with default Magento Aug 19, 2015 at 19:52
  • Actually code you showed with "default" and "always" run separately should work with cron.sh as well. Aug 19, 2015 at 19:56
  • also, thanks for mentioning scheduler_cron.sh, I use AOE_Scheduler and I've somehow missed that this one should be run instead of cron.sh. I will check it. Aug 19, 2015 at 19:56
  • I found I use 0.3.2 version of Aoe_Scheduler, and found 1.2.1 on github thanks to your advice for update. I'm trying to set cron base base on your advice, cron.php, cron.sh, scheduler_cron.sh Thank you! :)
    – Yohan
    Aug 23, 2015 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.