Crontab is used to automate repetitive tasks.
We can use command crontab -e to enter the editor mode and then add tasks we need.
crontab -l shows scheduled commands for particular user.
Ntpdate is a simple program that allows us to synchronise system time once. It's not so sophisticated as ntpd daemon that continuously synchronising system time, running in background.
It's usage is also simple: ntpdate servername
It can be really handy to combine it with crontab to synchronise system clock periodically.
Just do the following:
sudo crontab -e
@hourly /usr/sbin/ntpdate 1.it.pool.ntp.org
This crontab job should be executed as root or the date won't be synchronised.
Also, the path for the program in the crontab job should be a full path. Even so ntpdate servername command would work from terminal execution, it won't from crontab job. For crontab we have to specify the full path, e.g. /usr/sbin/ntpdate servername. That is a general rule for crontab.
To check the full path of the command, we can use which command.
For example, which ntpdate.
Crontab example:
0 */2 * * * /home/igro/Desktop/backupGNS
Following string allows us to execute backupGNS script every two hours.
Thanks for this information
ReplyDeleteCisco Training