5 kx .TH NETDATE 8L 85/08/21
5 kx .UC 4
5 kx .SH NAME
5 kx netdate \- set date and time by ARPA Internet RFC 868
5 kx .SH SYNOPSIS
5 kx .B
5 kx netdate
5 kx [ \-v ] [ \-l limit ] [ protocol ] hostname...
5 kx .SH DESCRIPTION
5 kx \fINetdate\fP takes a list of names of Internet hosts as arguments,
5 kx selects the one which supplies the best time, and sets
5 kx the system time accordingly.
5 kx The invoker must be the super-user for the time to be set.
5 kx Protocol names (either \fBudp\fP or \fBtcp\fP) may be
5 kx interspersed with the host names, and determine the
5 kx protocol which will be used to connect to the hosts
5 kx whose names follow, up to the next protocol name or
5 kx the end of the arguments.
5 kx The default protocol is \fBudp\fP.
5 kx .PP
5 kx The ``best'' time is chosen by polling the named hosts
5 kx once each to find their times and taking their differences
5 kx from the local host's time.
5 kx These differences are used to find the largest group of hosts
5 kx whose times agree with each other within a certain limit.
5 kx The first host in the largest group is picked as the best host.
5 kx (The assumption is that the hosts which are usually most accurate
5 kx will be named first.)
5 kx That host is polled again and the local host's time is set to the result.
5 kx The chosen host's time is checked on this second poll to insure that
5 kx its difference from the local host's time has not varied more than the limit
5 kx from its difference at the first poll.
5 kx .PP
5 kx The default limit is five seconds. It may be set with the \fB\-l\fP option.
5 kx The \fB\-v\fP option causes the groups to be shown.
5 kx The host name \fBlocalhost\fP is recognized as a synonym for the name
5 kx of the local host, no network connection is made for it, and its
5 kx time difference is always zero.
5 kx If \fBlocalhost\fP is chosen as having the best time,
5 kx the system time will not be set.
5 kx Hosts which do not respond are not counted in the groups.
5 kx If the limit is set to zero, the time is set to that of the
5 kx first host to respond and no other checking is done.
5 kx Supplying only one host name argument also sets the limit to zero.
5 kx .PP
5 kx While the RFC868 protocol only returns 32\ bits of data, containing
5 kx the time in seconds, \fInetdate\fP will accept an extra 32\ bits,
5 kx containing microseconds (expected to be accurate to no more than milliseconds).
5 kx Delays on long haul networks may make this extra precision useless,
5 kx but it is useful on local area networks.
5 kx The extra precision is not used on the first poll of a host,
5 kx but it is used on the second poll of the chosen host,
5 kx if that host supplies it.
5 kx .SH EXAMPLE
5 kx The most accurate hosts are named first in each example.
5 kx Some such call on \fInetdate\fP should be put at the end of
5 kx \fB/etc/rc.d/rc.local\fP,
5 kx so that the time will be set properly on system startup.
5 kx It is also useful to have a shell script, e.g., \fB/sbin/timehosts\fP,
5 kx which contains a call on \fInetdate\fP with arguments appropriate
5 kx to the local system, so that it is easy to set the time manually.
5 kx .SH "netdate -l 30 udp dcn\-gate tcp neighbor"
5 kx \fIDcn\-gate\fP is a hypothetical host which usually keeps time
5 kx accurate to within milliseconds of Coordinated Universal Time,
5 kx but may occasionally be eight hours off.
5 kx \fINeighbor\fP is a neighbor of the local host which keeps time
5 kx with moderate accuracy.
5 kx The time will be set to that of \fIdcn\-gate\fP if that and \fIneighbor\fP
5 kx agree to within thirty seconds, else it will not be set at all.
5 kx This is almost good enough for most circumstances, but won't do
5 kx when the local host's time is known to be wrong (e.g., after
5 kx a long downtime or a bad crash) and must be set to something.
5 kx If one of the hosts named is inaccurate or not responding, there is a problem.
5 kx .SH "netdate -l 30 udp dcn\-gate tcp neighbor neighbor2"
5 kx Only two of the three hosts named must agree on the time.
5 kx The time will still be set (to that of the first neighbor),
5 kx even if \fIdcn\-gate\fP is far off as long as the two neighbors agree.
5 kx This is probably good enough for most cases.
5 kx One can arbitrarily gerrymander the vote for more insurance
5 kx (and less clarity), as in the following example.
5 kx .SH "netdate\ udp\ dcn\-gate\ dcn1\ tcp\ bbn\-unix\ localhost\ neighbor"
5 kx Here \fIdcn1\fP and \fIbbn\-unix\fP are more hypothetical very accurate
5 kx timekeepers, at least one of which keeps time independently from
5 kx \fIdcn\-gate\fP, one hopes.
5 kx It is very likely that the time will be set to that one of those three
5 kx very accurate hosts, as long as at least two of them agree, or at least
5 kx one of them agrees with the neighbor or the local host's time.
5 kx If all the foreign hosts disagree, the time will not be set,
5 kx since \fBlocalhost\fP will be chosen as best.
5 kx .SH "netdate\ \-l\ 3\ localhost\ localhost\ udp\ dcn\-gate\ dcn1\ tcp\ bbn\-unix"
5 kx This example gives \fBlocalhost\fP two votes and declares it to usually
5 kx have the most accurate time.
5 kx All three foreign hosts must agree within three seconds
5 kx and also differ from \fBlocalhosts\fP by more than three seconds
5 kx for the time to be set.
5 kx Thus the time will be set only if it really needs to be.
5 kx .SH FILES
5 kx .nf
5 kx /etc/services for the time service port number
5 kx /etc/protocols for the protocol numbers
5 kx /var/log/wtmp to record time-setting
5 kx .SH SEE ALSO
5 kx ARPANET Request for Comments 868, gettimeofday(2), date(1),
5 kx WWV (USA):
5 kx 2.5,5,10,15 MHz AM for Coordinated Universal Time (UCT).
5 kx .SH DIAGNOSTICS