ntpdate(1Mtcp)
ntpdate --
set the date and time via NTP (Network Time Protocol)
Synopsis
ntpdate [ -Bbdosu ] [ -a key# ]
[ -e authdelay ] [ -k keyfile ]
[ -o version_number ]
[ -p samples ]
[ -t timeout ] server ...
Description
ntpdate sets the local date and time by polling
the Network Time Protocol server(s) on the host(s) given as
arguments to determine the correct time. It must be run as
root on the local host. A number of samples are obtained
from each of the servers specified and the standard
NTP clock filter and selection algorithms are
applied to select the best of these. Typically,
ntpdate can be inserted in the
/etc/inet/config startup script to set the time
of day at boot time and/or can be run from time-to-time via
cron(1M).
Note that ntpdate's reliability and precision
will improve dramatically with greater numbers of servers.
While a single server may be used, better performance and
greater resistance to insanity on the part of any one
server will be obtained by providing at least three or four
servers, if not more.
Time adjustments are made by ntpdate in one of
two ways. If ntpdate determines your clock is
off by more than 0.5 seconds it will simply step the time
by calling settimeofday.
If the error is less than 0.5 seconds, however, it will by
default slew the clock's time via a call to
adjtime(2)
with the offset. The latter technique is less disruptive
and more accurate when the offset is small, and works quite
well when ntpdate is run by cron
every hour or two. The adjustment made in the latter case
is actually 50% larger than the measured offset since this
will tend to keep a badly drifting clock more accurate (at
some expense to stability, though this tradeoff is usually
advantageous). At boot time, however, it is usually better
to always step the time.
Options
The following options are used to adjust or to get information
about ntpdate:
- -B
-
Force the time to be slewed using
adjtime(2)
even if the magnitude of the measured offset is greater than
128 milliseconds. The default behavior is to step the time using
settimeofday.
A host should not be used to synchronize clients in the
period of several hours it may take to slew the clock to the correct value.
- -b
-
Force time, in all cases, to be stepped.
Usually specified at boot time.
- -d
-
Print information useful for general debugging and give
information about ntpdate results without
performing ntpdate operations. This option
always uses unprivileged ports.
- -o
-
Force the program to poll as a version 1 or version 2
implementation. NTP, by default, identifies
itself as a version 3.4 implementation in its
outgoing packets. Some older versions of NTP
do not respond to version 3.x queries.
- -s
-
Tell ntpdate to log its actions using
syslog(3G),
rather than the standard output. This is
useful when running the program from cron.
- -u
-
Tell ntpdate to use an unprivileged port when
sending packets. This is most useful when synchronizing with
hosts beyond a firewall and sending packets
from behind a firewall that blocks incoming traffic to
privileged ports.
- -a
-
Specify that all packets should be authenticated using the
indicated key number (key#).
- -e
-
Specify an authentication processing delay in seconds
(authdelay). This number is usually small enough
to be negligible for ntpdate, but may improve time
keeping on very slow CPUs.
- -k
-
Enable file name modification for the file from which keys
may be read (keyfile). This file should be
in the format described in
xntpd(1Mtcp).
The default keys file is /etc/inet/ntp.keys.
- -p
-
Set the number of samples (samples) ntpdate
acquires from each server from 1 to 8 (inclusive). The default is 4.
- -t
-
Set the time spent waiting for a response (timeout).
This time is rounded to a multiple of 0.2 seconds. The default
is 1 second, a value suitable for polling across a LAN.
ntpdate will decline to set the date if an
NTP server daemon (for example,
xntpd(1Mtcp))
is running on the same host; this is because ntpdate and
xntpd both
bind to the same port (123). When running
ntpdate on a regular basis from cron
as an alternative to running a daemon, doing so once every
hour or two will result in precise enough timekeeping to
avoid stepping the clock.
Files
- /etc/inet/ntp.keys
-
contains the encryption keys used by ntpdate
Exit codes
None.
References
gettimeofday(2),
xntpd(1Mtcp)
RFC 1119, RFC 1305
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.