Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Recommended Cron Practices (SysAdvent Day 8) (sysadvent.blogspot.com)
29 points by keyist on Dec 8, 2009 | hide | past | favorite | 5 comments


My tip when using cron: Use comments liberally. Say what the command is doing, where to find out more information and write your name so that when I open up the crontab on some system I can actually find out what it is supposed to be doing. Comments are essential in a script which is not under any version control and is shared by many different users.


Your crontabs (as well as all other config files) should be under some form of version control.


Along those lines is etckeeper:

http://fnords.wordpress.com/2009/03/05/etckeeper-chronicles-...

Edit: if you are worried about your crontab files from users then version /var/spool/cron/


What you really want is a scheduler that can handle all this for you, so you don't have to write the same management gunk into every script you run with cron.

It would also be nice to be able to express "the first Saturday of each month" for backup jobs, so you don't have to run a script every Saturday which carefully avoids doing work after the 7th.


That scheduler is called launchd -- it cleanly replaces all of the "automatically launch a process" tools: not just init and cron (along with many greenspun variants), but also event-triggered stuff like xinetd and udev. It even implements the interfaces of its predecessors, so you don't need to run legacy daemons.

It was written by Apple for 10.4, and the code is real pretty: http://launchd.macosforge.org/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: