ntpdate is a Linux utility that is used to synchronize the date and time of a system with a remote Network Time Protocol (NTP) server. NTP is a protocol that is used to distribute time information over networks and is designed to keep the clocks of networked systems synchronized to within a few milliseconds of each other.
ntpdate is a client-side utility that can be used to set the date and time of a system by connecting to an NTP server and retrieving the current time. The retrieved time is then used to set the local clock of the system. This can be useful for systems that do not have a persistent network connection, as it allows the system to synchronize its time with an NTP server whenever a connection is available.
ntpdate is typically used as a one-time tool, run at boot time or whenever the time needs to be set or corrected. It is important to run ntpdate regularly in order to ensure that the time remains accurate and to prevent drift, which can cause problems with applications that depend on accurate timekeeping.
It’s important to note that ntpdate is considered deprecated and has been replaced by the more advanced ntpd service, which provides continuous time synchronization and is better suited for systems that require accurate timekeeping. However, ntpdate can still be useful for systems that only require periodic time synchronization, or for users who prefer a simpler and more lightweight solution.
ntpdate Command Examples
1. Quietly sync the local clock with two stratum 1 NTP servers:
# ntpdate -s time.nist.gov time-b.nist.gov
2. Synchronize and set date and time:
# ntpdate host
3. Query the host without setting the time:
# ntpdate -q host
4. Use an unprivileged port in case a firewall is blocking privileged ports:
# ntpdate -u host
5. Force time to be stepped using `settimeofday` instead of `slewed`:
# ntpdate -b host
The problem with ntpdate is that it matches server time with central time without considering the big drifts in local time, whereas the NTP daemon ntpd continuously adjusts the server time to match it with the reference clock. As mentioned in the ntpdate manual pages (man ntpdate), you can use ntpdate multiple times throughout a day to keep time drifts low and get more accurate results, but it does not match the accuracy and reliability provided by ntpd.