5 ms·
Reminds me of the time I accidentally typed in 'crontab -d' instead of 'crontab -e'. Those two letters are eerily too close to eachother.
by oluwie 11y ago
Reminds me of the time I accidentally typed in 'crontab -d' instead of 'crontab -e'.
Those two letters are eerily too close to eachother.
- laumars 11y agoI've managed that one as well. One month into a new job and working on servers with complex applications installed that I wasn't yet familiar with. Thankfully I had `crontab -l` just beforehand, otherwise I'd have been screwed.
- hrktb 11y agoMost admins have a text file somewhere with the contents of the crontab. Specially because these things happen more often than it should.
- laumars 11y agoIndeed. I do generally keep backups of crontabs, not just in case of this kind of scenario but also in case the platform blows up in any unexpected ways. Sadly the company in question didn't. However I have since made it a personal policy to always -l before editing so I have a "backup" in my tmux scroll back (that time I mentioned before, it was pure chance that I had -l)
- wahnfrieden 11y agoThis is one of the reasons why we have infrastructure as code now, so system changes can be reviewed and tested just like application code, and more types of accidents can be reverted via source control :)
- djsumdog 11y agoIn the article the guy is using ansible. He even had off-site backups, but they were mounted before his ansible playbooks ran, wiping them out as well.
- neotrinity 11y agodid you mean crontab -r ? I remember using crontab -r assuming that -r is to open it in read only mode. like vim -R Bad assumption!
- laumars 11y ago> did you mean crontab -r ? Some platforms it's -r, others it's -d. I suspect it's down to which cron daemon you run but never really cared enough to investigate. In any case, both are next to the 'e' key so either are just as dangerous in terms of typos.
- _kst_ 11y agoAnother dangerous command is `crontab` with no arguments. It reads a new crontab from standard input. If you type Ctrl-C, it will abort and leave your existing crontab in place. If you type Ctrl-D, you've just created a new empty crontab and clobbered your old one. My personal crontab is in a separate file in a source control system. I don't use `crontab -e`; I edit that file and feed it to the `crontab` command. (It would be nice if HN handled backticks the way they're done in Markdown.)
- jo909 11y agoA customer did this on his server once while I sat with him to add something. Since restoring the crontab from backups would have been a little inconvenient for such a small thing, I grepped the log files what commands were run by cron in what interval and had it rewritten in a few minutes.