Sometimes it is good to be able to automate some tasks that is run on regular basis, it’s here where crontab does the job. crontab is a scheduler for Linux/Unix where you can either add a command directly or a script with a lot of commands to be executed on set time intervals which you set as you please.
1. Edit crontab file for the user you want the job to run as, i use root as an example.
$ sudo crontab -u root -e
2. Add your desired entry in the format like this
60 * * * * /path/to/script/or/command
The format of the entry is, m h dom mon dow command.
m = Minutes(0-59)
h = hours, (0-23)
dom = Day Of Month(1-31)
mon = Month, values (1-12)
dow = Day Of Week(1-7)
command = The command that should be run on the specified time & date.
When running tar in a script run via crontab it often fails even when it runs fine from the console, this can be helped by adding ‘> /dev/null 2>&1′ at the end of the crontab entry your adding/have, must be before the last ‘&’ if there are one present at the end of the line.