Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

From that site:

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers including yum and pacman-g2) to automatically commit changes made to /etc during package upgrades. It tracks file metadata that revison control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It's quite modular and configurable, while also being simple to use if you understand the basics of working with revision control.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top