# Using NTP to Sync Time

Recently there was a strange error during code compilation. The compiler complained that the modified date is ahead of current time for some objects, thus it cannot figure out the correct dependencies. Because the source code is hosted on master node via NFS, we suspect the time between these two nodes are out of sync.

Within a cluster, it is important that the time at all node should be synced. . In other words, all the nodes must synchronize with the same reference server for time. This achieved by Network Time Protocal (NTP). Usually the connection to NTP server is established upon bootup, but it can be manually restarted to sync the time.

# check if NTP is installed on Centos/RHEL
$chkconfig --list ntpd ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off # stop NTP service if NTP is installed and working$ service ntp stop


The -gq below tells the NTP daemon to correct the time regardless of the offset (g) and exit immediately (q) after setting the time.

$ntpd -gq$ service ntp start


Welcome back to the future!