Linux: crontab syntax check
The folder /etc/cron.d/ is used to store all cronjobs, the cronjob is saved on the file , the format is:
minute hour day month dayofweek username command_to_run.
There might some problems – the syntax is not correct , and the result is that the whole file will be ignore. I don’t know how to check the syntax , but i can watch to the syslog to see if there is any error. After we edit the file in crontab , the system will reload the cronjob, if there is any error it will throw an error in syslog. So i setup this before editing the cronjob file:
1 |
tail -f /var/log/syslog | grep cron & |
After i edit, wait for sometimes, if there is an error we’ll see this:
1 2 |
Sep 9 05:33:01 onetwothree[1155]: (*system*web_cron) ERROR (Syntax error, this crontab file will be ignored) Sep 9 05:33:01 onetwothree cron[1155]: (*system*web_cron) RELOAD (/etc/cron.d/web_cron) |
Hope it help.
Leave a Reply