2000-01-12 14:41:00 +00:00
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2006-05-17 10:50:35 +00:00
|
|
|
.Dd May 17, 2006
|
2000-01-12 14:41:00 +00:00
|
|
|
.Dt NTPDATE 8
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm ntpdate
|
|
|
|
.Nd set the date and time via NTP
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
2006-05-17 10:50:35 +00:00
|
|
|
.Op Fl 46bBdoqsuv
|
2000-01-12 14:41:00 +00:00
|
|
|
.Op Fl a Ar key
|
|
|
|
.Op Fl e Ar authdelay
|
|
|
|
.Op Fl k Ar keyfile
|
|
|
|
.Op Fl o Ar version
|
|
|
|
.Op Fl p Ar samples
|
|
|
|
.Op Fl t Ar timeout
|
2001-08-29 14:50:56 +00:00
|
|
|
.Ar server ...
|
2000-01-12 14:41:00 +00:00
|
|
|
.Sh DESCRIPTION
|
2001-08-29 14:50:56 +00:00
|
|
|
.Em Note :
|
|
|
|
The functionality of this program is now available
|
|
|
|
in the
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8
|
2001-08-29 14:50:56 +00:00
|
|
|
program.
|
|
|
|
See the
|
2002-01-21 20:12:02 +00:00
|
|
|
.Fl q
|
2001-08-29 14:50:56 +00:00
|
|
|
command line
|
|
|
|
option in the
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8
|
2001-08-29 14:50:56 +00:00
|
|
|
page.
|
|
|
|
After a suitable period of
|
|
|
|
mourning, the
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2002-07-14 14:47:15 +00:00
|
|
|
utility is to be retired from this
|
2001-08-29 14:50:56 +00:00
|
|
|
distribution.
|
2000-01-12 14:41:00 +00:00
|
|
|
.Pp
|
2002-07-14 14:47:15 +00:00
|
|
|
The
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2002-07-14 14:47:15 +00:00
|
|
|
utility sets the local date and time by polling the
|
2001-08-29 14:50:56 +00:00
|
|
|
Network Time Protocol (NTP) server(s) given as the
|
|
|
|
.Ar server
|
|
|
|
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 a subset of the NTP clock filter and
|
|
|
|
selection algorithms are applied to select the best of these.
|
|
|
|
Note
|
|
|
|
that the accuracy and reliability of
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
depends on
|
|
|
|
the number of servers, the number of polls each time it is run and
|
|
|
|
the interval between runs.
|
2000-01-12 14:41:00 +00:00
|
|
|
.Pp
|
|
|
|
The following options are available:
|
|
|
|
.Bl -tag -width indent
|
2006-05-17 10:50:35 +00:00
|
|
|
.It Fl 4
|
|
|
|
Force DNS resolution of following host names on the command line to the
|
|
|
|
IPv4 namespace.
|
|
|
|
.It Fl 6
|
|
|
|
Force DNS resolution of following host names on the command line to the
|
|
|
|
IPv6 namespace.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl a Ar key
|
2001-08-29 14:50:56 +00:00
|
|
|
Enable the authentication function and specify the key
|
|
|
|
identifier to be used for authentication as the argument
|
2002-01-21 20:12:02 +00:00
|
|
|
.Ar key .
|
2000-01-12 14:41:00 +00:00
|
|
|
The keys and key identifiers must match
|
|
|
|
in both the client and server key files.
|
2001-08-29 14:50:56 +00:00
|
|
|
The default is to disable
|
|
|
|
the authentication function.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl B
|
|
|
|
Force the time to always be slewed using the
|
|
|
|
.Xr adjtime 2
|
2001-08-29 14:50:56 +00:00
|
|
|
system
|
|
|
|
call, even if the measured offset is greater than +-128 ms.
|
|
|
|
The
|
|
|
|
default is to step the time using
|
2000-01-12 14:41:00 +00:00
|
|
|
.Xr settimeofday 2
|
2001-08-29 14:50:56 +00:00
|
|
|
if the offset is
|
|
|
|
greater than +-128 ms.
|
|
|
|
Note that, if the offset is much greater
|
2002-01-21 20:12:02 +00:00
|
|
|
than +-128 ms in this case, it can take a long time (hours) to
|
2001-08-29 14:50:56 +00:00
|
|
|
slew the clock to the correct value.
|
2002-01-21 20:12:02 +00:00
|
|
|
During this time, the host
|
2001-08-29 14:50:56 +00:00
|
|
|
should not be used to synchronize clients.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl b
|
|
|
|
Force the time to be stepped using the
|
|
|
|
.Xr settimeofday 2
|
2001-08-29 14:50:56 +00:00
|
|
|
system
|
|
|
|
call, rather than slewed (default) using the
|
2000-01-12 14:41:00 +00:00
|
|
|
.Xr adjtime 2
|
|
|
|
system call.
|
2001-08-29 14:50:56 +00:00
|
|
|
This option should be used when called from a startup file at boot
|
|
|
|
time.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl d
|
2001-08-29 14:50:56 +00:00
|
|
|
Enable the debugging mode, in which
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
will go
|
|
|
|
through all the steps, but not adjust the local clock.
|
|
|
|
Information
|
|
|
|
useful for general debugging will also be printed.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl e Ar authdelay
|
2001-08-29 14:50:56 +00:00
|
|
|
Specify the processing delay to perform an authentication
|
|
|
|
function as the value
|
2000-01-12 14:41:00 +00:00
|
|
|
.Ar authdelay ,
|
|
|
|
in seconds and fraction
|
|
|
|
(see
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8
|
2000-01-12 14:41:00 +00:00
|
|
|
for details).
|
2001-08-29 14:50:56 +00:00
|
|
|
This number is usually small
|
|
|
|
enough to be negligible for most purposes, though specifying a
|
|
|
|
value may improve timekeeping on very slow CPU's.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl k Ar keyfile
|
2001-08-29 14:50:56 +00:00
|
|
|
Specify the path for the authentication key file as the string
|
2000-01-12 14:41:00 +00:00
|
|
|
.Ar keyfile .
|
|
|
|
The default is
|
|
|
|
.Pa /etc/ntp.keys .
|
2001-08-29 14:50:56 +00:00
|
|
|
This file
|
|
|
|
should be in the format described in
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8 .
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl o Ar version
|
2004-10-20 10:11:12 +00:00
|
|
|
Specify the NTP version for outgoing packets as the integer
|
2000-01-12 14:41:00 +00:00
|
|
|
.Ar version ,
|
|
|
|
which can be 1 or 2.
|
|
|
|
The default is 3.
|
|
|
|
This allows
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2000-01-12 14:41:00 +00:00
|
|
|
to be used with older NTP versions.
|
|
|
|
.It Fl p Ar samples
|
|
|
|
Specify the number of samples to be acquired from each server
|
|
|
|
as the integer
|
|
|
|
.Ar samples ,
|
|
|
|
with values from 1 to 8 inclusive.
|
|
|
|
The default is 4.
|
|
|
|
.It Fl q
|
2005-02-13 22:25:33 +00:00
|
|
|
Query only - do not set the clock.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl s
|
2001-08-29 14:50:56 +00:00
|
|
|
Divert logging output from the standard output (default) to the
|
|
|
|
system
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr syslog 3
|
2000-01-12 14:41:00 +00:00
|
|
|
facility.
|
2001-08-29 14:50:56 +00:00
|
|
|
This is designed primarily for
|
|
|
|
convenience of
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr cron 8
|
2000-01-12 14:41:00 +00:00
|
|
|
scripts.
|
2000-06-22 08:45:59 +00:00
|
|
|
.It Fl t Ar timeout
|
2001-08-29 14:50:56 +00:00
|
|
|
Specify the maximum time waiting for a server response as the
|
|
|
|
value
|
2000-01-12 14:41:00 +00:00
|
|
|
.Ar timeout ,
|
|
|
|
in seconds and fraction.
|
2002-01-21 20:12:02 +00:00
|
|
|
The value is
|
2001-08-29 14:50:56 +00:00
|
|
|
rounded to a multiple of 0.2 seconds.
|
|
|
|
The default is 1 second, a
|
|
|
|
value suitable for polling across a LAN.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl u
|
|
|
|
Direct
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
|
|
|
to use an unprivileged port for outgoing
|
2001-08-29 14:50:56 +00:00
|
|
|
packets.
|
|
|
|
This is most useful when behind a firewall that blocks
|
|
|
|
incoming traffic to privileged ports, and you want to synchronise
|
|
|
|
with hosts beyond the firewall.
|
2000-01-12 14:41:00 +00:00
|
|
|
Note that the
|
2002-01-21 20:12:02 +00:00
|
|
|
.Fl d
|
2001-08-29 14:50:56 +00:00
|
|
|
option
|
|
|
|
always uses unprivileged ports.
|
2000-01-12 14:41:00 +00:00
|
|
|
.It Fl v
|
|
|
|
Be verbose.
|
|
|
|
This option will cause
|
|
|
|
.Nm Ns 's
|
2001-08-29 14:50:56 +00:00
|
|
|
version
|
|
|
|
identification string to be logged.
|
2000-01-12 14:41:00 +00:00
|
|
|
.El
|
2001-08-29 14:50:56 +00:00
|
|
|
.Pp
|
2002-07-14 14:47:15 +00:00
|
|
|
The
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2002-07-14 14:47:15 +00:00
|
|
|
utility can be run manually as necessary to set the
|
2001-08-29 14:50:56 +00:00
|
|
|
host clock, or it can be run from the host startup script to set
|
|
|
|
the clock at boot time.
|
|
|
|
This is useful in some cases to set the
|
|
|
|
clock initially before starting the NTP daemon
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8 .
|
2001-08-29 14:50:56 +00:00
|
|
|
It is
|
|
|
|
also possible to run
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
from a
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr cron 8
|
2001-08-29 14:50:56 +00:00
|
|
|
script.
|
|
|
|
However, it is important to note that
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
with
|
|
|
|
contrived
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr cron 8
|
2001-08-29 14:50:56 +00:00
|
|
|
scripts is no substitute for the NTP
|
|
|
|
daemon, which uses sophisticated algorithms to maximize accuracy
|
|
|
|
and reliability while minimizing resource use.
|
|
|
|
Finally, since
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
does not discipline the host clock frequency as
|
|
|
|
does
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8 ,
|
2001-08-29 14:50:56 +00:00
|
|
|
the accuracy using
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
is
|
|
|
|
limited.
|
|
|
|
.Pp
|
|
|
|
Time adjustments are made by
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
in one of two
|
|
|
|
ways.
|
|
|
|
If
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
determines the clock is in error more
|
|
|
|
than 0.5 second it will simply step the time by calling the system
|
|
|
|
.Xr settimeofday 2
|
|
|
|
routine.
|
|
|
|
If the error is less than 0.5
|
|
|
|
seconds, it will slew the time by calling the system
|
|
|
|
.Xr adjtime 2
|
|
|
|
routine.
|
|
|
|
The latter technique is less disruptive
|
|
|
|
and more accurate when the error is small, and works quite well
|
|
|
|
when
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
is run by
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr cron 8
|
2001-08-29 14:50:56 +00:00
|
|
|
every hour or
|
|
|
|
two.
|
|
|
|
.Pp
|
2002-07-14 14:47:15 +00:00
|
|
|
The
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2002-07-14 14:47:15 +00:00
|
|
|
utility will decline to set the date if an NTP server
|
2001-08-29 14:50:56 +00:00
|
|
|
daemon (e.g.,
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8 )
|
2001-08-29 14:50:56 +00:00
|
|
|
is running on the same host.
|
|
|
|
When
|
|
|
|
running
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
on a regular basis from
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr cron 8
|
2001-08-29 14:50:56 +00:00
|
|
|
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.
|
|
|
|
.Pp
|
2006-05-17 10:50:35 +00:00
|
|
|
Note that in contexts where a host name is expected, a
|
|
|
|
.Fl 4
|
|
|
|
qualifier preceding the host name forces DNS resolution to the
|
|
|
|
IPv4 namespace, while a
|
|
|
|
.Fl 6
|
|
|
|
qualifier forces DNS resolution to the IPv6 namespace.
|
|
|
|
.Pp
|
2001-08-29 14:50:56 +00:00
|
|
|
If NetInfo support is compiled into
|
2002-11-27 15:25:07 +00:00
|
|
|
.Nm ,
|
2001-08-29 14:50:56 +00:00
|
|
|
then the
|
2006-05-17 10:50:35 +00:00
|
|
|
.Cm server
|
2001-08-29 14:50:56 +00:00
|
|
|
argument is optional if
|
2002-01-21 20:12:02 +00:00
|
|
|
.Nm
|
2001-08-29 14:50:56 +00:00
|
|
|
can find a
|
|
|
|
time server in the NetInfo configuration for
|
2002-01-21 20:12:02 +00:00
|
|
|
.Xr ntpd 8 .
|
2000-01-12 14:41:00 +00:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /etc/ntp.keys -compact
|
|
|
|
.It Pa /etc/ntp.keys
|
|
|
|
contains the encryption keys used by
|
2000-11-20 20:10:44 +00:00
|
|
|
.Nm .
|
2000-01-12 14:41:00 +00:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr ntpd 8
|
|
|
|
.Sh BUGS
|
2001-08-29 14:50:56 +00:00
|
|
|
The slew adjustment is actually 50% larger than the measured
|
|
|
|
offset, since this (it is argued) will tend to keep a badly
|
|
|
|
drifting clock more accurate.
|
|
|
|
This is probably not a good idea and
|
|
|
|
may cause a troubling hunt for some values of the kernel variables
|
|
|
|
.Va kern.clockrate.tick
|
2000-01-12 14:41:00 +00:00
|
|
|
and
|
2001-08-29 14:50:56 +00:00
|
|
|
.Va kern.clockrate.tickadj .
|