Contents
Is there a backup of crontab?
4 Answers. You could just backup the entire /var/spool/cron directory. It contains all crontabs of all users. You can periodically run crontab -l > my_crontab.
How do I find my cron job history?
The simplest way to validate that cron tried to run the job is to simply check the appropriate log file; the log files however can be different from system to system. In order to determine which log file contains the cron logs we can simply check the occurrence of the word cron in the log files within /var/log .
How can I restore accidentally deleted crontab entries?
I was trying to create a cron on the production environment and so I created crontab.txt file with my new cron command and ran crontab crontab.txt file but instead of appending to existing cron job list, it accidently deleted all crons and now I only have my cron on prod. How can I retreive earlier crons that were set and append my new cron to it.
How to recover cron jobs accidentally removed in Linux?
So if you did not make a backup, your only recovery options are: On RedHat/CentOS, if your jobs have been triggered before, you can find the cron log in /var/log/cron. Another option is to recover the file using a file recovery tool. On Ubuntu/Debian, if your task has run before, try grep CRON /var/log/syslog
Where to find Cron log in RedHat / CentOS?
On RedHat/CentOS, if your jobs have been triggered before, you can find the cron log in /var/log/cron. The file will help you rewrite the jobs again. Another option is to recover the file using a file recovery tool.
Is there a way to grep a cron file?
If you remember a specific line, you can grep the whole device to find your data back, at the condition that no other data overwrote it. This works for any file. Adjust -B (efore) and -A (fter) to your file size, but 100 lines around should be enough for a cron file. The -a parameter is needed to force grep to consider your device as text.