too many crons - too many machines !

Solution 1:

The answer is automation (cfengine/puppet/bcfg2/chef/others). But those won't really help you unless you can keep them under strict control. You can easily obtain that in two steps:

  • get a source code management repository running - i recommend subversion to start with
  • integrate the scm with an automation tool of your choice

So move all your crons in /etc/cron.d/ and use a naming scheme that accomodates your systems. Second , put all /etc/cron.d/ directories in subversion and have local checkouts on each machine. You will be able to manage everything manually and have a history of your changes, be able to track any machines that do not have the latest crontabs and so forth. Then you can get an automation software to do all this for you.

If you really need something quick and dirty you should have a single file , let's say /etc/cron.d/all-jobs , deployed on on all machines and decide in that file if a cron is supposed to run or not based on the hostname. Something like:

*/5 * * * * root [[ $HOSTNAME == 'myhostname' ]] && /usr/bin/job.sh

This is not very efficient but it should make your life easier until you get some automation going on.

Solution 2:

Configuration management systems such as Puppet, Capistrano and CFEngine are tools which will do this and a whole lot more.

If you're having to manage many machines for cron, you'll probably have a bunch of other things you have to configure on those machines too, so sooner or later you'll need to investigate more than just managing the cronjobs...

They have very good tutorials and documentation on the Puppet site (see here), and they're not too painful to get set up.

If it's hundreds of machines, get up and running with them as soon as you can and you'll wonder how you managed to cope without them (even for something simple like just pushing the cronjobs to lots of machines)!

Solution 3:

With a configuration management tool like puppet (or cfengine, bcfg2, etc.), you can manage a lot more than crontabs from a centralized location.