How did I wipe out all my cron jobs?
If you type crontab
with no arguments, it reads a crontab from standard input. If you then type Control-D, it will create an empty crontab, overwriting your previous crontab. (Control-C aborts the command and leaves your crontab alone.)
jpmath's answer correctly points out that crontab -r
will also wipe out your cron jobs (that's what it's for).
I avoid this by (almost) never using crontab -e
(edit crontab) or crontab
with no arguments (which reads from stdin). Instead, I keep my crontab entries in a separate file, which I maintain in a source control system, and run the crontab
command with that file name as an argument. (I'll occasionally use crontab -e
to make temporary changes.)
(I temporarily clobbered my own crontab while writing this answer, knowing that I could recover it.)
If you type crontab -r
instead of crontab -e
by mistake (e
and r
are next to each other), your crontab will be removed as well.