Monday, 23 July 2018

crontab cheat sheet

crontab cheat sheet
After all these years of managing crontab entries, I made an error the other day, causing a job to run on a wrong day. Oops.
I used to have a handy cheat sheet I'd insert at the top of /etc/crontab, but a while back stopped, thinking I've graduated past it. Clearly not, but my web searches for one didn't turn up any I liked. So made my own. Here it is in case anyone else needs handholding:
#+--------------- minute (0-59)
#| +------------- hour (0-23)
#| | +----------- day of month (1-31)
#| | | +--------- month (1-12)
#| | | | +------- day of week (0-7), 0=Sunday
#| | | | |     user    command
17 * * * *     root    cd / && run-parts --report /etc/cron.hourly
25 6 * * *     root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7     root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * *     root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

# your custom jobs here...

0 comments:

Post a Comment