ntpdate

Set the local time and date by polling NTP servers

Syntax:

ntpdate [-46bBdqsuv] [-a key] [-e authdelay] 
        [-k keyfile] [-M i=your_hostname] 
        [-o version]  [-p samples] 
        [-t timeout] server [...]  

Runs on:

Neutrino

Options:

-4
Force DNS resolution of hosts to the IP4 namespace.
-6
Force DNS resolution of hosts to the IP6 namespace.
-a key
Enable the authentication function, where key is the key identifier. Both keys and the key identifiers must match the client and server key files. The default is to disable the authentication function.
-B
Force the time to always be adjusted using ClockAdjust(), even if the measured offset is larger than ±128 milliseconds. The default is to set the time using settimeofday(). In case the offset is much greater than ±128 milliseconds, a longer time (in hours) may be needed to adjust the clock to the correct value. During this time, the host is not used to synchronize clients.
-b
Force the time to be stepped using the settimeofday() function call. You should use this option when calling from a startup file at boot time.
-d
Enable the debugging mode, after going through all the steps. Don't adjust the local clock. Print the useful information.
-e authdelay
Specify the processing delay authdelay (in seconds and fractions thereof) to perform an authentication function. This option improves timekeeping for slow CPUs. You may neglect it for most purposes.
-k keyfile
Specify the path for the authentication key file as the string keyfile. The default is /etc/ntp/ntp.keys. For information about this file, see its entry in the FreeBSD documentation.
-M i=your_hostname
Enable your host to listen broadcast and multicast messages.
-o version
Specify the NTP version, which can be either 1 or 2 or 3. The default is 3. Use this option to use ntpdate with an older NTP version.
-p samples
Specify the number of samples acquire from each server. The range is 1 to 8; the default is 4.
-q
Query the clock; don't set it.
-s
Divert logging output to the system syslog facility. This is designed primarily for the convenience of cron scripts.
-t timeout
Specify the maximum time for a server response — in seconds and fractions thereof. The value is rounded to a multiple of 0.2 seconds. The default is 1 second, a value suitable for polling across a LAN.
-u
Direct ntpdate to use an unprivileged port for outgoing packets. This is most useful when a firewall blocks incoming traffic to privileged ports, and you want to synchronize with hosts beyond the firewall. Note that the -d option always uses unprivileged ports.
-v
Be verbose. Log the ntpdate version identification string.

Description:

Use the ntpdate utility to set the local time and date by polling NTP (Network Time Protocol) servers. The accuracy and reliability of this utility depends on the number of servers, the number of polls each time it is run, and the interval between runs.


Note: Run the ntpdate utility as root on the local host.

At boot time, you may use a host startup script to run the ntpdate utility in order to set the clock. If necessary, you can also run this utility manually. Using the host script to set time initially is sometimes useful, e.g. set the time before you start the NTP daemon, ntpd. You can also run ntpdate from a cron script. The accuracy of the ntpdate utility is limited.

You use an -M option to support broadcast and multicast messages. Use -M i=hostname to join the multicast group. You are now able to listen for broadcast and multicast messages from an broadcast/multicast enabled server.

Use the ntpdate utility to adjust time in two ways:

The latter technique is less disruptive and more accurate when the error is small, and works quite well when ntpdate is run by cron every hour or two.

When the ntpd utility is running on the same host, the ntpdate utility doesn't set the date.

You may force the DNS resolution to the IPv4 (or IPv6) namespace, if you use a -4 (or -6) option that precedes a host name.

Caveats:

Since the time adjustment is actually 50% larger than the measured offset, it tends to keep a badly drifting clock more accurate. This is not good, however, for some kernel variables such as tick or tickadj.

See also:

ntpd, ntpdc, ntpq, ntptrace

ClockAdjust(), settimeofday() in the Neutrino Library Reference

ntp.keys in the FreeBSD documentation