1.\" 2.\" $FreeBSD$ 3.\" 4.Dd January 6, 2000 5.Dt NTPDATE 8 6.Os 7.Sh NAME 8.Nm ntpdate 9.Nd set the date and time via NTP 10.Sh SYNOPSIS 11.Nm 12.Op Fl bBdoqsuv 13.Op Fl a Ar key 14.Op Fl e Ar authdelay 15.Op Fl k Ar keyfile 16.Op Fl o Ar version 17.Op Fl p Ar samples 18.Op Fl t Ar timeout 19.Ar server ... 20.Sh DESCRIPTION 21.Pp 22.Em Note : 23The functionality of this program is now available 24in the 25.Xr ntpd 8 26program. 27See the 28.Fl q 29command line 30option in the 31.Xr ntpd 8 32page. 33After a suitable period of 34mourning, the 35.Nm 36program is to be retired from this 37distribution. 38.Pp 39.Nm 40sets the local date and time by polling the 41Network Time Protocol (NTP) server(s) given as the 42.Ar server 43arguments to determine the correct time. 44It must be run as root on 45the local host. 46A number of samples are obtained from each of the 47servers specified and a subset of the NTP clock filter and 48selection algorithms are applied to select the best of these. 49Note 50that the accuracy and reliability of 51.Nm 52depends on 53the number of servers, the number of polls each time it is run and 54the interval between runs. 55.Pp 56The following options are available: 57.Bl -tag -width indent 58.It Fl a Ar key 59Enable the authentication function and specify the key 60identifier to be used for authentication as the argument 61.Ar key . 62The keys and key identifiers must match 63in both the client and server key files. 64The default is to disable 65the authentication function. 66.It Fl B 67Force the time to always be slewed using the 68.Xr adjtime 2 69system 70call, even if the measured offset is greater than +-128 ms. 71The 72default is to step the time using 73.Xr settimeofday 2 74if the offset is 75greater than +-128 ms. 76Note that, if the offset is much greater 77than +-128 ms in this case, it can take a long time (hours) to 78slew the clock to the correct value. 79During this time, the host 80should not be used to synchronize clients. 81.It Fl b 82Force the time to be stepped using the 83.Xr settimeofday 2 84system 85call, rather than slewed (default) using the 86.Xr adjtime 2 87system call. 88This option should be used when called from a startup file at boot 89time. 90.It Fl d 91Enable the debugging mode, in which 92.Nm 93will go 94through all the steps, but not adjust the local clock. 95Information 96useful for general debugging will also be printed. 97.It Fl e Ar authdelay 98Specify the processing delay to perform an authentication 99function as the value 100.Ar authdelay , 101in seconds and fraction 102(see 103.Xr ntpd 8 104for details). 105This number is usually small 106enough to be negligible for most purposes, though specifying a 107value may improve timekeeping on very slow CPU's. 108.It Fl k Ar keyfile 109Specify the path for the authentication key file as the string 110.Ar keyfile . 111The default is 112.Pa /etc/ntp.keys . 113This file 114should be in the format described in 115.Xr ntpd 8 . 116.It Fl o Ar version 117Specify the NTP version for outgoint packets as the integer 118.Ar version , 119which can be 1 or 2. 120The default is 3. 121This allows 122.Nm 123to be used with older NTP versions. 124.It Fl p Ar samples 125Specify the number of samples to be acquired from each server 126as the integer 127.Ar samples , 128with values from 1 to 8 inclusive. 129The default is 4. 130.It Fl q 131Query only - don't set the clock. 132.It Fl s 133Divert logging output from the standard output (default) to the 134system 135.Xr syslog 3 136facility. 137This is designed primarily for 138convenience of 139.Xr cron 8 140scripts. 141.It Fl t Ar timeout 142Specify the maximum time waiting for a server response as the 143value 144.Ar timeout , 145in seconds and fraction. 146The value is 147rounded to a multiple of 0.2 seconds. 148The default is 1 second, a 149value suitable for polling across a LAN. 150.It Fl u 151Direct 152.Nm 153to use an unprivileged port for outgoing 154packets. 155This is most useful when behind a firewall that blocks 156incoming traffic to privileged ports, and you want to synchronise 157with hosts beyond the firewall. 158Note that the 159.Fl d 160option 161always uses unprivileged ports. 162.It Fl v 163Be verbose. 164This option will cause 165.Nm Ns 's 166version 167identification string to be logged. 168.El 169.Pp 170.Nm 171can be run manually as necessary to set the 172host clock, or it can be run from the host startup script to set 173the clock at boot time. 174This is useful in some cases to set the 175clock initially before starting the NTP daemon 176.Xr ntpd 8 . 177It is 178also possible to run 179.Nm 180from a 181.Xr cron 8 182script. 183However, it is important to note that 184.Nm 185with 186contrived 187.Xr cron 8 188scripts is no substitute for the NTP 189daemon, which uses sophisticated algorithms to maximize accuracy 190and reliability while minimizing resource use. 191Finally, since 192.Nm 193does not discipline the host clock frequency as 194does 195.Xr ntpd 8 , 196the accuracy using 197.Nm 198is 199limited. 200.Pp 201Time adjustments are made by 202.Nm 203in one of two 204ways. 205If 206.Nm 207determines the clock is in error more 208than 0.5 second it will simply step the time by calling the system 209.Xr settimeofday 2 210routine. 211If the error is less than 0.5 212seconds, it will slew the time by calling the system 213.Xr adjtime 2 214routine. 215The latter technique is less disruptive 216and more accurate when the error is small, and works quite well 217when 218.Nm 219is run by 220.Xr cron 8 221every hour or 222two. 223.Pp 224.Nm 225will decline to set the date if an NTP server 226daemon (e.g., 227.Xr ntpd 8 ) 228is running on the same host. 229When 230running 231.Nm 232on a regular basis from 233.Xr cron 8 234as 235an alternative to running a daemon, doing so once every hour or two 236will result in precise enough timekeeping to avoid stepping the 237clock. 238.Pp 239If NetInfo support is compiled into 240.Nm , 241then the 242.Ic server 243argument is optional if 244.Nm 245can find a 246time server in the NetInfo configuration for 247.Xr ntpd 8 . 248.Sh FILES 249.Bl -tag -width /etc/ntp.keys -compact 250.It Pa /etc/ntp.keys 251contains the encryption keys used by 252.Nm . 253.El 254.Sh SEE ALSO 255.Xr ntpd 8 256.Sh BUGS 257The slew adjustment is actually 50% larger than the measured 258offset, since this (it is argued) will tend to keep a badly 259drifting clock more accurate. 260This is probably not a good idea and 261may cause a troubling hunt for some values of the kernel variables 262.Va kern.clockrate.tick 263and 264.Va kern.clockrate.tickadj . 265