143 lines
4.2 KiB
Groff
Raw Normal View History

1998-02-19 08:05:46 +00:00
.\"
.\" $Id$
.\"
.Dd December 21, 1993
.Dt NTPDATE 8
.Os
.Sh NAME
.Nm ntpdate
.Nd set the date and time via NTP
.Sh SYNOPSIS
.Nm
.Op Fl bds
.Op Fl o Ar version
.Op Fl a Ar key#
.Op Fl e Ar authdelay
.Op Fl k Ar keyfile
.Op Fl p Ar samples
.Op Fl t Ar timeout
.Ar server ...
.Sh DESCRIPTION
.Nm Ntpdate
1993-12-21 18:36:48 +00:00
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,
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
can be inserted in the
1998-02-19 08:05:46 +00:00
.Pa /etc/rc.local
1993-12-21 18:36:48 +00:00
startup up script to set the time of day at boot time and/or can be run
from time\-to\-time via
1998-02-19 08:05:46 +00:00
.Xr cron 8 .
1993-12-21 18:36:48 +00:00
Note that
1998-02-19 08:05:46 +00:00
.Nm Ns 's
1993-12-21 18:36:48 +00:00
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.
1998-02-19 08:05:46 +00:00
.Pp
1993-12-21 18:36:48 +00:00
Time adjustments are made by
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
in one of two ways. If
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
determines your clock is off by more than 0.5 seconds it will simply
step the time by calling
1998-02-19 08:05:46 +00:00
.Xr settimeofday 2 .
1993-12-21 18:36:48 +00:00
If the error is less than 0.5 seconds, however, it will by default slew
the clock's time via a call to
1998-02-19 08:05:46 +00:00
.Xr adjtime 2
1993-12-21 18:36:48 +00:00
with the offset. The latter technique is less disruptive and more
accurate when the offset is small, and works quite well when
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
is run by
1998-02-19 08:05:46 +00:00
.Xr cron 8
1993-12-21 18:36:48 +00:00
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. This can be forced
in all cases by specifying the
1998-02-19 08:05:46 +00:00
.Fl b
1993-12-21 18:36:48 +00:00
switch on the command line. The
1998-02-19 08:05:46 +00:00
.Fl s
1993-12-21 18:36:48 +00:00
switch tells
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
to log its actions via the
1998-02-19 08:05:46 +00:00
.Xr syslog 3
1993-12-21 18:36:48 +00:00
facility rather than to the standard output, a useful option when
running the program from
1998-02-19 08:05:46 +00:00
.Xr cron 8 .
.Pp
1993-12-21 18:36:48 +00:00
The
1998-02-19 08:05:46 +00:00
.Fl d
1993-12-21 18:36:48 +00:00
flag may be used to determine what
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
will do without it actually doing it. Information useful for general
debugging will also be printed. By default
1998-02-19 08:05:46 +00:00
.Nm
claims to be an NTP version 3 implementation in its outgoing packets. As
some older software will decline to respond to version 3 queries, the
1998-02-19 08:05:46 +00:00
.Fl o Ar version
switch can be used to force the program to poll as a version 2 or 1
implementation instead.
1998-02-19 08:05:46 +00:00
.Pp
1993-12-21 18:36:48 +00:00
The number of samples
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
acquires from each server can be set to between 1 and 8 inclusive
using the
1998-02-19 08:05:46 +00:00
.Fl p
1993-12-21 18:36:48 +00:00
switch. The default is 4. The time it will spend waiting for a
response can be set using the
1998-02-19 08:05:46 +00:00
.Fl t
1993-12-21 18:36:48 +00:00
switch, and will be rounded to a multiple of 0.2 seconds. The default
is 1 second, a value suitable for polling across a LAN.
1998-02-19 08:05:46 +00:00
.Pp
.Nm Ntpdate
1993-12-21 18:36:48 +00:00
will authenticate its transactions if need be. The
1998-02-19 08:05:46 +00:00
.Fl a
1993-12-21 18:36:48 +00:00
switch specifies that all packets should be authenticated using the
key number indicated. The
1998-02-19 08:05:46 +00:00
.Fl k
1993-12-21 18:36:48 +00:00
switch allows the name of the file from which the keys may be read
to be modified from the default of
1998-02-19 08:05:46 +00:00
.Pa /etc/ntp.keys .
1993-12-21 18:36:48 +00:00
This file should be in the format described in
1998-02-19 08:05:46 +00:00
.Xr xntpd 8 .
1993-12-21 18:36:48 +00:00
The
1998-02-19 08:05:46 +00:00
.Fl e
1993-12-21 18:36:48 +00:00
option allows the specification of an authentication processing delay,
in seconds (see
1998-02-19 08:05:46 +00:00
.Xr xntpd 8
1993-12-21 18:36:48 +00:00
for details). This number is usually small enough to be negligible for
1998-02-19 08:05:46 +00:00
.Nm Ns 's
1993-12-21 18:36:48 +00:00
purposes, though specifying a value may improve timekeeping on very slow
CPU's.
1998-02-19 08:05:46 +00:00
.Pp
.Nm Ntpdate
1993-12-21 18:36:48 +00:00
will decline to set the date if an NTP server daemon (e.g.
1998-02-19 08:05:46 +00:00
.Xr xntpd 8 )
1993-12-21 18:36:48 +00:00
is running on the same host. When running
1998-02-19 08:05:46 +00:00
.Nm
1993-12-21 18:36:48 +00:00
on a regular basis from
1998-02-19 08:05:46 +00:00
.Xr cron 8
1993-12-21 18:36:48 +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.
1998-02-19 08:05:46 +00:00
.Sh FILES
.Bl -tag -width /etc/ntp.keys -compact
.It Pa /etc/ntp.keys
contains the encryption keys used by
.Nm Ns .
.El
.Sh SEE ALSO
.Xr xntpd 8
.Sh HISTORY
Written by
.An Dennis Ferguson
at the University of Toronto
.Sh BUGS
1993-12-21 18:36:48 +00:00
The technique used for improving accuracy by compensating for clock
oscillator errors sucks, but doing better would require the program
to save state from previous runs.