Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

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...
share|improve this answer
add comment

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
share|improve this answer
add comment

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.

share|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 '12 at 1:24
    
Sadly, not everyone uses Vi..... –  Magellan Jan 19 '12 at 2:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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