The night before I was trying to update some cron jobs setup on one of our processing servers for work as I need to get a report to our BDM the next morning. I have used crontab for quite a while without much of issues, however, that night I typed in “crontab -r” instead of “crontab -e” to edit the crontab. I didn’t even know what “crontab -r” does, but when I corrected my mistake and retype in “crontab -e” only to realise that all of my crontab definitions were gone.

I was in a panic and did “man crontab” and only to find out that “-r” means “remove without warning”. “Holy shit” I said to myself because we don’t have backups. Luckily one of our system admins was online and he was able to help me to recover most of the cron job definitions by checking the cron log.

I can imagine lots of people wouldn’t know that “crontab -r” is to remove current crontab definition without warning and surprising the option for editing (-e) and removing (-r) are next to each other.

Now we really need to backup crontab regularly otherwise sooner or later there will be another mistake.

Leave a Reply

Your email address will not be published. Required fields are marked *