The recommended way to synchronize time using NTP

datentptime

This question has come up a number of times in a localized way, this question is meant to provide the preferred/best method for synchronizing a system's clock using NTP.

The solution should handle multiple issues correctly, such as:

  1. Correct for time at boot-up quickly where the clock has a large skew.

  2. Provide a configuration that guards and/or corrects for situations where the clock can sometimes develop a large skew over time.

  3. A robust solution that can handle and sync the time quickly when certain problems arise such as: "the time server wasn't accessible during boot" or "the internet is inaccessible during boot".

The ideal solution would be a single NTP configuration file that is able to handle all this.

References

Many of the pieces that will provide the "ultimate" solution are spread across the U&L site in questions such as these:

There are bound to be others but these are the ones that I've seen that come to mind as being relevant.

Best Answer

Since you cannot correct large deviations in time using ntp (unless you have a few hours for the clock to catch up or slow down) I do this:

service ntpd stop
ntpdate us.pool.ntp.org
service ntpd start

I cron it for once a day, everyday. I also put ntpdate in an init script to run before ntp starts after bootup, since reboots and power cycles are the most likely/frequent events that mess with the system time.

Related Question