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:
-
Correct for time at boot-up quickly where the clock has a large skew.
-
Provide a configuration that guards and/or corrects for situations where the clock can sometimes develop a large skew over time.
-
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:
- How to force the time and date settings to refresh from the internet?
- Time synchronization of machines on LAN to GPS NTP server on the LAN
- How can I make a Puppet module that fixes time?
- NTP not syncing in a VM
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:
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.