Cron jobs can be easily removed simply by providing a wrong options. I usually use the command ‘crontab -e’ to add/modify all my scheduled cron jobs. (In fact, I just mistyped e as r haha) Sometimes, I mistyped to option ‘r’ instead of ‘e’ which in fact will removed all my cron jobs according to this. When the moment I first did it, I panicked. Searched online and was trying to figure out how to recover this. Then, I got this idea of creating a bash script/command line tool that will help others to recover from disaster. And, here is what I did.
Say, one day you accidentally did this. You do not need to panicked because you got me. I will walk you through how to use this script to recover all your deleted cron jobs.
First step, you need to download the latest released version of the bash script from my GitHub repo.
Go to the directory and run the script like this,
You will be promoted to input your scheduled time like this,
At the end, you can find the ready-to-go command from the stdout or output.txt file. Hint: Use command ‘crontab -e’ to add/modify your cron jobs.
Hopefully this guide has help you to recover from the incident. Thank you for reading!
I’ll try to keep this list current and up to date. If you know of a great resource you’d like to share or notice a broken link, please let us know.