Magento Cron.sh Not Working

Sometimes the Magento cron stops working. You can monitor this using the great AOE Scheduler module. There are basic checks that you can do to ensure that you have your cron setup to work as you want, for example setting file permissions, setting up the bin/sh to hit the correct file (*/5 * * * * /bin/sh /server/path/to/cron.sh) and making sure that the cron is setup in the correct user’s crontab. However sometimes it still doesn’t work and that can be down to an issue in the formatting of cron.sh.

You can find out if there is an issue with the cron.sh file by running (where useraccount is the name of the web server user) in the terminal from the site root:

$ su - useraccount
$ sh cron.sh
$ cron.sh: line 29: syntax error: unexpected end of file

The error shows that there is a problem, for example incorrect line endings, or similar. This can be fixed by running the following with dos2unix:

$ dos2unix cron.sh
$ dos2unix: converting file cron.sh to UNIX format ...
$ su - useraccount
$ sh cron.sh

Now check that the cron is running and you should be all set.

Steve Perry profile image

Written by Steve Perry
Published on

Latest Articles

View All