I have CentOS machine and each time I've noticed that the server loses correct time after a while. It is usually behind by several minutes after time passes from having manually set the correct time. Is there a mechanism whereby I can update the server with the time from a specific time server?
yum install ntp chkconfig ntpd on
Do an initial sync, with
and start the time daemon with:
Ntpd does exactly what you're looking for - synchronizes your system clock with one or more known-good time servers.
Basically there are two ways. NTP daemon and the ntpdate command. The most important difference is that ntpdate will synchronize the time at once even though it means that the system time will change. On the other hand NTP daemon will take care of the time synchronization and it will adjust the time by small steps - you can think about it like slowing down/speeding up the time of the computer to synchronize it to the correct time. Thats why people suggest to do the initial synchronization by ntpdate and then leave it to ntp daemon.