Cron – Dynamic crontab file

cron

Is it possible to make cron receive it's instructions from the output of a shell script instead of reading a static file?

I'm trying to manage crontabs across a bunch of machines and maintaining separate crontab files for each machine is a chore. I'd like cron to instead run a shell script that prints out crontab lines for each job based on whether a given machine is assigned to that job. Can I do this?

P.S.- I've seen some suggest Puppet/Chef/etc. for this purpose, but I think that's overkill for handling just this one problem.

Best Answer

I think the easiest way to do this on most distributions would be using automated deployment tools like Puppet/Chef as well as the /etc/cron.d directory. You can place crontabs in that directory, except they use the following format rather than the typical one:

* * * * * <user> <command>

Where is the user that will be running the cron.

You seem to think Puppet is overkill (it's not), but the directory part would apply to any other solution as well.