Written by Steve Perry
Published on

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 Creative Ltd

Studio and registered office: 4 Back Lane, Brown Edge, Staffordshire ST6 8QS.

Copyright © 2012 – 2023 Steve Perry Creative Ltd., unless otherwise noted.

Registered in England & Wales, number 08354632.

Colophon

Typeset in Söhne Kräftig and Söhne Buch, by Klim Type Co.

Set as 32/64, 24/32, 20/32, and 12/16 on an 8px/96px grid.

Colour palette selected for AAA contrast.