5 ms·
A cron job kicks off that makes the whole system unresponsive, undergoing heavy swap (updatedb used to do this and ran every night on many default systems). So
by cma 10y ago
A cron job kicks off that makes the whole system unresponsive, undergoing heavy swap (updatedb used to do this and ran every night on many default systems).
Someone edits a cron file in the most common editor, vim. On many systems it doesn't do an atomic swap on save without extra configuration: http://stackoverflow.com/questions/13563627/how-does-vim-save-files http://stackoverflow.com/questions/13563627/how-does-vim-sav...
Now maybe your unresponsive, undergoing swap, system misses a cron job that was present in both edits. Opps.
I'm not sure this could really play out, but the approach definitely sounds firmly on the "worse is better" side of the scale.
- krunaldo 10y agocrontab -e is the way to edit your cron. A similar command exists for editing the sudoers file which is visudo. This will ensure your configuration is a valid syntax as well as do an atomic swap of the file. Otherwise adding a file or deleting a file in /etc/cron.d/ is the way to go for automatic(ansbile, puppet etc) and package installations.
- krrrh 10y agoI'm surprised that people would edit cron in any other way, crontab -e is one of the first commands most intro to Linux manuals teaches. However crontab -r has to be one of the most poorly thought out commands in UNIX. It removes the cron file and since r is only one character over from e on qwerty keyboards it's a painful and surprising typo.
- efiala 10y agowhat if you are managing the crons externally, eg puppet, crontab -e is not always option
- Godel_unicode 10y ago1. If you don't have a test process for changes made with puppet, this is hardly a problem with cron. 2. Puppet handled that parsing for you and will throw errors if your syntax is wrong
- hibbelig 10y agoUse /bin/cat as editor. That should work nicely from Puppet.
- _ao789 10y agoI can't tell you the amount of times I've hit -r by mistake and regretted it..
- michaelcampbell 10y agoI can. 0. There, more anecdata. Honestly though, I never use `-e` either. I keep a ~/.crontab and edit that, and then `crontab ~/.crontab`. Voila, backup/time machine/git friendly crontab.
- dajohnson89 10y agoHave a cronjob that backs up your crontab?
- benjojo12 10y agoI got bit by this once, and had to rescue the crontab out off the disk with GNU strings :(
- mooneater 10y agofirst thing when logging into new server: place /etc under git. then loss of cron files (or any config file) is easily recovered from.
- Drdrdrq 10y agoThis is a brilliant idea - thank you!
- mooneater 10y agoI cannot count the number of times this has helped or saved me. You can keep the /etc git repo local. Or if its a critical server, push to github private repo. Seeing a history of your /etc edits is a very reassuring feeling.
- pferde 10y agoExcept that crontabs are usually somewhere in /var. :)
- mooneater 10y agoWhich is why I only use system-wide crontabs, in /etc/cron.d Instead of per-user crontabs. Much easier to manage. With cron.d you can specify what user each cron entry should run as, so it is equivalent.
- Animats 10y agocrontab -e is the way to edit your cron. A similar command exists for editing the sudoers file which is visudo. This will ensure your configuration is a valid syntax as well as do an atomic swap of the file. And there's "vipw" for the password file. Each of them with their own separate updating bugs.
- jstimpfle 10y ago"Worse is better" is an oxymoron. You can also read it as "better is worse". In "worse is better", the "worse" isn't really worse in practical settings (considering all tradeoffs, giving appropriate weights to design goals, etc.). Nobody argues that there can't be problems. What all critics miss is to show how to avoid these problems. What can you do about jobs that make the system unresponsive? Not a problem for cron to solve. If someone writes a crontab (instead of rename()ing another version over it), that's not cron's fault. Sqlite databases can be just as easily corrupted or lose integrity. Now which format would you rather repair? Missing a cron job can not be totally avoided, and it isn't the end of the world. What if your machine goes down or cron crashes? The answer is that the jobs themselves have to be provided with some resilience against that situation. This isn't a case of "worse is better" since there weren't proposed solutions to the "problems" at all, however unrealistic.
- pekeler 10y agoThis is a perfect example for why you ought to monitor all your cronjobs with something like https://wdt.io https://wdt.io.