Sometimes it is necessary to ensure the system clock of all systems is synchronized. E.g. when running a virtual machine, depending on your virtualization technology and your settings your system clock may diverge. This can be achieved by updating the system clock using ntpd
regularly.
Executing a command regularly can be easily done with cron
. Updating the system time is possible via ntpd
. So simply add a file to /etc/cron.*
, e.g. /etc/cron.daily
and add the command for updating system clock there. So once a day your system time will be updated. Of course you can do that more often or maybe once a month only. But I think once a day is quite good enough for a huge number of scenarios.
#!/bin/sh ntpd -g -q
-g
in case there is a difference > 1000s
-q
for exiting ntpd right after setting the system clock the first time
Sources
man ntpd