TrumanWong

ntpdate

Set date and time using Network Timing Protocol (NTP)

Supplementary instructions

ntpdate command is used to set the local date and time. It obtains a number of samples from each server specified and applies standard NTP clock filters and selection algorithms to select the best samples.

The ntpdate command uses the following methods for time adjustment:

  • If it determines that the clock is off by more than 0.5 seconds, it sets the clock time by calling the settimeofday subroutine. At boot time, this is a preferred method.
  • If it determines that the clock offset is less than 0.5 seconds, it adjusts the clock time by calling the adjtime subroutine and the offset. This method tends to keep the drift clock more accurate at the expense of some stability. When running the ntpdate command regularly from a cron command rather than running a daemon, executing it every hour or two can ensure sufficient time accuracy to avoid adjusting the clock.

Using many servers can greatly improve the reliability and accuracy of the ntpdate command. Although a single server is possible, you can get better performance by provisioning at least three or four servers.

If an NTP server daemon like the xntpd daemon is running on the same host, the command will deny the ntpdate set date.

You must have root privileges to run this command on the host.

grammar

ntpdate [ -b] [ -d] [ -s] [ -u] [ -aKeyid] [ -eAuthenticationDelay] [ -kKeyFile] [ -oVersion] [ -pSamples] [ -tTimeOut] Server...

Options

-aKeyid # Use Keyid to authenticate all packets.
-b # Increase the clock time by calling the settimeofday subroutine.
-d #Specify debugging mode. Determines what the ntpdate command will produce (no actual results will be produced). The results are reproduced on the screen. This flag uses an unprivileged port.
-eAuthenticationDelay # Specify the number of seconds to delay authentication processing.
-kKeyFile # Specify a different name for the file containing the keys when not using the default /etc/ntp.keys file. See the description of the file KeyFile.
-oVersion # Specifies the NTP version implementation to use when polling for its outgoing packets. The value of Version can be 1, 2, 3. The default value is 3.
-pSamples # Specify the number of samples to obtain from each server. The value of Samples is between 1 and 8, inclusive. Its default value is 4.
-s # Specify the use of the syslog facility for logging operations instead of using standard output. It is useful when running ntpdate command and cron command.
-tTimeOut #Specify the time to wait for a response. The value of the given TimeOut is rounded to multiples of 0.2 seconds. The default value is 1 second.
-u # Specify an unprivileged port to send packets. This is useful when behind a firewall that blocks incoming traffic on privileged ports, and wants to synchronize with the host outside the firewall. A firewall is a system or computer that controls access to a private network from the outside.
-q # For query only, no time is set.