More Than Just Web Design | INTERNET ENGINEERING | APPLICATION | DESIGN
A Cronic Misunderstanding
You Do The Same Thing For Years And Suddenly It's Wrong
I've been using Unix/Linux systems for more years than I care to remember, but today I got caught out. This little gem concerns the cron task scheduler.
I was endeavouring to configure an auto currency update for a Zen Cart installation I was setting up, but would it run? No way. Even more bizarre was the lack of any error message or other indication that something was amiss.
The user crontab was correctly formatted:
5 2 * * * /home/jero/bin/myscript > /tmp/log 2>&1
and installing the file with the crontab command returned without error. The cron daemon itself was running and was producing output in the syslog file. Hmmm. Time to RTFM.
At the end of the crontab man page, there's a BUGS section:
- Although cron requires that each entry in a crontab end in a newline character, neither the crontab command nor the cron daemon will detect this error. Instead, the crontab will appear to load normally. However, the command will never run. The best choice is to ensure that your crontab has a blank line at the end.
I tried again, adding a blank line to the end of the crontab, and sure as eggs is eggs, everything burst into life. It transpires that the installation of the joe editor was partly to blame here, since joe does not, by default add a trailing newline character but does become the default editor. Good old vi, which I have used for aeons, has no such problem.