Tasks automatisation: the cron daemon

From Elvanör's Technical Wiki
Jump to navigation Jump to search

General help and syntax

  • man crontab gives you useful examples. Be careful that the first number represents the minutes NOT the hours.

Crontab Editing

  • You should not edit by hand /etc/crontab. This system wide file may not even exist (on Gentoo it does not exist for example). Instead use
crontab -e -u username

This will edit the user crontab, and ensure that changes are notified to the crond daemon.

Crontab Debugging

  • When debugging crontab scripts, *make sure* that the script runs OK first. Run it as it would be loaded from the crontab daemon, and verify that no problems occur.

Notes

  • Some outdated articles on the Net do no longer apply to recent versions of OS X. In particular, there is no additional column in the crontab for the user under which the command is to be ran. The format is basically the same as in Linux.