views:

281

answers:

3

I've got a few dozen Linux machines running cron and I'd like to put the crontabs in some sort of revision control system. For source control I use Mercurial (hg), so that'd be ideal, but if there's some other system that is better suited to this task I'd consider it.

One aspect which is specific to my situation is that all the crontabs belong to a common user (not a real person, but a placeholder "services" login). I'd like the revision history to include the actual author of each change, rather than the special account where the cron jobs actually run.

+1  A: 

http://joey.kitenet.net/code/etckeeper/ ?

Daniel Bungert
This is kind of all right, but not really a full solution for my needs. A curiosity, I'd say, but so far I've ended up implementing something myself (nothing complex enough to be worth posting code for...basically just a monitoring script which checks `crontab -l` output against a VCS repo.
John Zwinck
+1  A: 

crontab -l dumps your crontab to standard output, which you could redirect to a file. You could have a job (in cron, naturally) to redirect this to a file which is then diffed, and pushed to source control as necessary.

bradheintz
Yes but then there's no room for commit comments nor author attribution.
John Zwinck
This answer is closest to what we ended up doing. We just skip the automatic commit to VCS, because we want the author and comment fields to be correct. So we issue warning emails if people forget to check in their changes to the repository. It works kind of OK, but could still stand improvement.
John Zwinck
A: 

If the linux system follows the LFS (linux filesystem standard, IIRC), then /etc should only contain config files. I had pretty good experience by importing the whole of /etc into CVS.

The only problem is that only root could commit changes, so it was a bit hard to see who broke something. This can be solved by assigning every admin a 3 letter short name and setting up the rule that each commit must start with this name.

Aaron Digulla