I don’t know exactly, why on earth crontab default key for edit(-e) and remove(-r) was designed sitting next to each other. Accidentally all cron jobs may be removed by entering -r, while trying to edit. So be careful!
How to recover:
- If you have backups, that’s great, restore from there.
- If no backup, find the cron jobs from log file using command:$
cat /var/log/cron | grep -v your_command.
- Repeatedly recover commands from log file.
Always maintain a file containing all crontab entries and keep it in code repository(e.g git). Then at any time, you can get from repo and re-store in unix.