Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I never edit a crontab directly. I use external files and reinstall them with "crontab filename" as needed. Then of course the files can be revision-controlled.

Also, I name the files according to host so I remember exactly where they were installed in a networked environment (e.g. "host1.crontab", "host2.crontab").



Interesting, newbie question: where do you put the x.crontab file and how do you get the system to run it? Thanks


I put per-user crontab stuff in ~/.cron/ not only cron-specific scripts go there, but ~/.cron/crontab is the (inactive) master copy of the crontab itself.

Make changes active with `crontab ~/.cron/crontab`

Diff with `diff -du <(crontab -l) <(cat ~/.cron/crontab)`

For servers or not-my-own-user crontabs, config management is the way to go. The crontabs should be in a config management repository, so there's not just a single copy that's deployed and active.


x.crontab can live wherever you'd like; you can even delete it after you install the crontab. When you run the following command

  crontab x.crontab
your crontab file is replaced by the contents of x.contrab; or if you want to install x.crontab for another user

  crontab -u www-user x.crontab
The actual location of x.crontab does not matter as it is just used to setup your cron jobs, but the system does not actually read from this file to run the jobs.




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

Search: