How to Backup Crontab Job List in Crontab Job?


The crontab is a job executor that can be set to run at a given specified interval. The command crontab -l will list the current job lists one item per line. The crontab -e allows you to edit the list of jobs in default editor e.g. vim, nano.

For example,

@reboot crontab -l > /var/www/crontab/$(date +\%Y-\%m-\%d)

says that on each system reboot, backup the list of crontab jobs and put it at folder /var/www/crontab and the name is given as current date. Please note that we do need to escape the percentage symbol in the crontab because it means newline characters, and all data after the first % will be sent to the command as standard input.

To change the frequency of the crontab jobs, you can use the format:

# m h  dom mon dow   command

For example,

0 0 * * * means at 00:00AM every day.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
215 words
Last Post: Review: Razer Blackwidow 2014 Expert Mechanical USB Keyboard
Next Post: How to Count The Number of General Exceptions (C#) using PowerShell to Adapter in Jenkins Build Server?

The Permanent URL is: How to Backup Crontab Job List in Crontab Job?

Leave a Reply