I'm currently confronted with a cron file that contains a dozen different applications' tasks--some have only one, some have lots. I'm trying to figure out a good way to organize and document these processes. Are there any conventions out there that I could emulate or am I stuck making something up?

link|improve this question
feedback

3 Answers

#minute hour    mday    month   wday    who     command

## Acme Anvil Application
# clear logs every 5 minutes
*/5     *       *       *       *       root    /path/to/clear_logs
# monthly maintenance
30      5       1       *       *       root    /path/to/acme/maintenance

## Fabricam
# adjust timing
*/30    0-5     *       *       *       fab    /path/to/bin/fab_time

## Etc...
link|improve this answer
feedback

If your system supports /etc/cron.d, you may also try breaking up the cron jobs into individual files, grouped by application.

root@linuxbox:/etc/cron.d# ls
sa-update  sysstat  vnstat

Note that the format of cron jobs in /etc/cron.d is a little different, in that you would put the user running the command in between the time fields and the command itself, e.g.,

root@linuxbox:/etc/cron.d# cat sa-update
### OPTIONAL: Spamassassin Rules Updates ###
#
# http://wiki.apache.org/spamassassin/RuleUpdates
# Highly recommended that you read the documentation before using this.
# ENABLE UPDATES AT YOUR OWN RISK.
#
# /var/log/sa-update.log contains a history log of sa-update runs

10 4 * * * root /usr/share/spamassassin/sa-update.cron 2>&1 | tee -a /var/log/sa-update.log
link|improve this answer
feedback

I would recommend ensuring that you have a comment at the end of your /etc/crontab file. Many implementations of cron won't fire off the last job in the file if it's not terminated with a Line Feed.

Debian Lenny being one of them.

link|improve this answer
Interesting point. I edit my crontab with vim, which won't let me create a text file without a terminating newline unless I ask it very nicely. (Text files without a newline on the last line can cause a lot of problems.) – Keith Thompson Jan 19 at 1:24
Sadly, not everyone uses Vi..... – Adrian Jan 19 at 2:01
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.