ntpdate: command not found

ntpdate is used to set the time of the local system to match a remote NTP host. The maintainers of the ntp code intend to drop ntpdate in the future since ntpd can perform essentially the same function when used with the -q option. The ntpdate command sets the current system time by contacting a timeserver machine on the network. You must be root to set the system time.

# /usr/sbin/ntpdate timeserver.someplace.edu
 7 Sep 21:01:25 ntpdate[2399]: step time server xx.xx.xx.xx
   offset 0.51 sec
Note: To keep your system date in sync with a timeserver over long periods, use the daemon ntpd instead.

Command Line Options

Option Description
-b Using this option, the system time is set instead of being slowly adjusted, no matter how far off the local time is.
-d This option enables debugging mode. ntpdate goes through the motions and prints debugging information but does not actually set the local clock.
-p n Use this option to specify the number of samples (where n is from 1 to 8) to get from each server. The default is 4.
-q This option causes ntpdate to query the servers listed on the command line without actually setting the clock.
-s This option causes all output from ntpdate to be logged via syslog instead of being printed to stdout.
-t n This option sets the timeout for a response from any server to n seconds.
-v This option makes ntpdate more verbose.

If you encounter below error while running the ntpdate command:

ntpdate: command not found

you may try installing the ntpdate package as shown below as per your choice of distribution.

Distribution Command
OS X brew install ntpdate
Debian apt-get install ntpdate
Ubuntu apt-get install ntpdate
Arch Linux pacman -S ntpdate
Kali Linux apt-get install ntpdate
CentOS yum install ntpdate
Fedora dnf install ntpdate
Raspbian apt-get install ntpdate

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

Conclusion

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.

Related Post