sntp.1sntpmdoc revision 275970
1.Dd December 19 2014 2.Dt SNTP 1sntpmdoc User Commands 3.Os 4.\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc) 5.\" 6.\" It has been AutoGen-ed December 19, 2014 at 07:51:38 AM by AutoGen 5.18.5pre4 7.\" From the definitions sntp-opts.def 8.\" and the template file agmdoc-cmd.tpl 9.Sh NAME 10.Nm sntp 11.Nd standard Simple Network Time Protocol client program 12.Sh SYNOPSIS 13.Nm 14.\" Mixture of short (flag) options and long options 15.Op Fl flags 16.Op Fl flag Op Ar value 17.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc 18[ hostname\-or\-IP ...] 19.Pp 20.Sh DESCRIPTION 21.Nm 22can be used as an SNTP client to query a NTP or SNTP server and either display 23the time or set the local system's time (given suitable privilege). It can be 24run as an interactive command or from a 25.Ic cron 26job. 27NTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol) 28are defined and described by RFC 5905. 29.Pp 30The default is to write the estimated correct local date and time (i.e. not 31UTC) to the standard output in a format like: 32.Ic "'1996\-10\-15 20:17:25.123 (+0800) +4.567 +/\- 0.089 [host] IP sN'" 33where the 34.Ic "'(+0800)'" 35means that to get to UTC from the reported local time one must 36add 8 hours and 0 minutes, 37the 38.Ic "'+4.567'" 39indicates the local clock is 4.567 seconds behind the correct time 40(so 4.567 seconds must be added to the local clock to get it to be correct). 41Note that the number of decimals printed for this value will change 42based on the reported precision of the server. 43.Ic "'+/\- 0.089'" 44is the reported 45.Em synchronization distance 46(in seconds), which represents the maximum error due to all causes. 47If the server does not report valid data needed to calculate the 48synchronization distance, this will be reported as 49.Ic "'+/\- ?'" . 50If the 51.Em host 52is different from the 53.Em IP , 54both will be displayed. 55Otherwise, only the 56.Em IP 57is displayed. 58Finally, the 59.Em stratum 60of the host is reported. 61.Sh "OPTIONS" 62.Bl -tag 63.It Fl 4 , Fl \-ipv4 64Force IPv4 DNS name resolution. 65This option must not appear in combination with any of the following options: 66ipv6. 67.sp 68Force DNS resolution of the following host names on the command line 69to the IPv4 namespace. 70.It Fl 6 , Fl \-ipv6 71Force IPv6 DNS name resolution. 72This option must not appear in combination with any of the following options: 73ipv4. 74.sp 75Force DNS resolution of the following host names on the command line 76to the IPv6 namespace. 77.It Fl a Ar auth\-keynumber , Fl \-authentication Ns = Ns Ar auth\-keynumber 78Enable authentication with the key \fBauth\-keynumber\fP. 79This option takes an integer number as its argument. 80.sp 81Enable authentication using the key specified in this option's 82argument. The argument of this option is the \fBkeyid\fP, a 83number specified in the \fBkeyfile\fP as this key's identifier. 84See the \fBkeyfile\fP option (\fB\-k\fP) for more details. 85.It Fl b Ar broadcast\-address , Fl \-broadcast Ns = Ns Ar broadcast\-address 86Listen to the address specified for broadcast time sync. 87This option may appear an unlimited number of times. 88.sp 89If specified \fBsntp\fP will listen to the specified address 90for NTP broadcasts. The default maximum wait time 91can (and probably should) be modified with \fB\-t\fP. 92.It Fl c Ar host\-name , Fl \-concurrent Ns = Ns Ar host\-name 93Concurrently query all IPs returned for host\-name. 94This option may appear an unlimited number of times. 95.sp 96Requests from an NTP "client" to a "server" should never be sent 97more rapidly than one every 2 seconds. By default, any IPs returned 98as part of a DNS lookup are assumed to be for a single instance of 99\fBntpd\fP, and therefore \fBsntp\fP will send queries to these IPs 100one after another, with a 2\-second gap in between each query. 101.sp 102The \fB\-c\fP or \fB\-\-concurrent\fP flag says that any IPs 103returned for the DNS lookup of the supplied host\-name are on 104different machines, so we can send concurrent queries. 105.It Fl d , Fl \-debug\-level 106Increase debug verbosity level. 107This option may appear an unlimited number of times. 108.sp 109.It Fl D Ar number , Fl \-set\-debug\-level Ns = Ns Ar number 110Set the debug verbosity level. 111This option may appear an unlimited number of times. 112This option takes an integer number as its argument. 113.sp 114.It Fl g Ar milliseconds , Fl \-gap Ns = Ns Ar milliseconds 115The gap (in milliseconds) between time requests. 116This option takes an integer number as its argument. 117The default 118.Ar milliseconds 119for this option is: 120.ti +4 121 50 122.sp 123Since we're only going to use the first valid response we get and 124there is benefit to specifying a good number of servers to query, 125separate the queries we send out by the specified number of 126milliseconds. 127.It Fl K Ar file\-name , Fl \-kod Ns = Ns Ar file\-name 128KoD history filename. 129The default 130.Ar file\-name 131for this option is: 132.ti +4 133 /var/db/ntp\-kod 134.sp 135Specifies the filename to be used for the persistent history of KoD 136responses received from servers. If the file does not exist, a 137warning message will be displayed. The file will not be created. 138.It Fl k Ar file\-name , Fl \-keyfile Ns = Ns Ar file\-name 139Look in this file for the key specified with \fB\-a\fP. 140.sp 141This option specifies the keyfile. 142\fBsntp\fP will search for the key specified with \fB\-a\fP 143\fIkeyno\fP in this file. See \fBntp.keys(5)\fP for more 144information. 145.It Fl l Ar file\-name , Fl \-logfile Ns = Ns Ar file\-name 146Log to specified logfile. 147.sp 148This option causes the client to write log messages to the specified 149\fIlogfile\fP. 150.It Fl M Ar number , Fl \-steplimit Ns = Ns Ar number 151Adjustments less than \fBsteplimit\fP msec will be slewed. 152This option takes an integer number as its argument. 153The value of 154.Ar number 155is constrained to being: 156.in +4 157.nf 158.na 159greater than or equal to 0 160.fi 161.in -4 162.sp 163If the time adjustment is less than \fIsteplimit\fP milliseconds, 164slew the amount using \fBadjtime(2)\fP. Otherwise, step the 165correction using \fBsettimeofday(2)\fP. 166.It Fl o Ar number , Fl \-ntpversion Ns = Ns Ar number 167Send \fBint\fP as our NTP protocol version. 168This option takes an integer number as its argument. 169The value of 170.Ar number 171is constrained to being: 172.in +4 173.nf 174.na 175in the range 0 through 7 176.fi 177.in -4 178The default 179.Ar number 180for this option is: 181.ti +4 182 4 183.sp 184When sending requests to a remote server, tell them we are running 185NTP protocol version \fIntpversion\fP . 186.It Fl r , Fl \-usereservedport 187Use the NTP Reserved Port (port 123). 188.sp 189Use port 123, which is reserved for NTP, for our network 190communications. 191.It Fl S , Fl \-step 192OK to 'step' the time with \fBsettimeofday(2)\fP. 193.sp 194.It Fl s , Fl \-slew 195OK to 'slew' the time with \fBadjtime(2)\fP. 196.sp 197.It Fl t Ar seconds , Fl \-timeout Ns = Ns Ar seconds 198The number of seconds to wait for responses. 199This option takes an integer number as its argument. 200The default 201.Ar seconds 202for this option is: 203.ti +4 204 5 205.sp 206When waiting for a reply, \fBsntp\fP will wait the number 207of seconds specified before giving up. The default should be 208more than enough for a unicast response. If \fBsntp\fP is 209only waiting for a broadcast response a longer timeout is 210likely needed. 211.It Fl \-wait , " Fl \-no\-wait" 212Wait for pending replies (if not setting the time). 213The \fIno\-wait\fP form will disable the option. 214This option is enabled by default. 215.sp 216If we are not setting the time, wait for all pending responses. 217.It Fl \&? , Fl \-help 218Display usage information and exit. 219.It Fl \&! , Fl \-more\-help 220Pass the extended usage information through a pager. 221.It Fl > Oo Ar cfgfile Oc , Fl \-save\-opts Oo Ns = Ns Ar cfgfile Oc 222Save the option state to \fIcfgfile\fP. The default is the \fIlast\fP 223configuration file listed in the \fBOPTION PRESETS\fP section, below. 224The command will exit after updating the config file. 225.It Fl < Ar cfgfile , Fl \-load\-opts Ns = Ns Ar cfgfile , Fl \-no\-load\-opts 226Load options from \fIcfgfile\fP. 227The \fIno\-load\-opts\fP form will disable the loading 228of earlier config/rc/ini files. \fI\-\-no\-load\-opts\fP is handled early, 229out of order. 230.It Fl \-version Op Brq Ar v|c|n 231Output version of program and exit. The default mode is `v', a simple 232version. The `c' mode will print copyright information and `n' will 233print the full copyright notice. 234.El 235.Sh "OPTION PRESETS" 236Any option that is not marked as \fInot presettable\fP may be preset 237by loading values from configuration ("RC" or ".INI") file(s) and values from 238environment variables named: 239.nf 240 \fBSNTP_<option\-name>\fP or \fBSNTP\fP 241.fi 242.ad 243The environmental presets take precedence (are processed later than) 244the configuration files. 245The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP". 246If any of these are directories, then the file \fI.ntprc\fP 247is searched for within those directories. 248.Sh USAGE 249.Bl -tag -width indent 250.It Li "sntp ntpserver.somewhere" 251is the simplest use of this program 252and can be run as an unprivileged command 253to check the current time and error in the local clock. 254.It Li "sntp \-a ntpserver.somewhere" 255With suitable privilege, 256run as a command 257or from a 258.Xr cron 8 259job, 260.Ic "sntp \-a" 261will reset the local clock from a synchronized specified server, 262like the (deprecated) 263.Xr ntpdate 1ntpdatemdoc , 264or 265.Xr rdate 8 266commands. 267.El 268.Sh "ENVIRONMENT" 269See \fBOPTION PRESETS\fP for configuration environment variables. 270.Sh "FILES" 271See \fBOPTION PRESETS\fP for configuration files. 272.Sh "EXIT STATUS" 273One of the following exit values will be returned: 274.Bl -tag 275.It 0 " (EXIT_SUCCESS)" 276Successful program execution. 277.It 1 " (EXIT_FAILURE)" 278The operation failed or the command syntax was not valid. 279.It 66 " (EX_NOINPUT)" 280A specified configuration file could not be loaded. 281.It 70 " (EX_SOFTWARE)" 282libopts had an internal operational error. Please report 283it to autogen\-users@lists.sourceforge.net. Thank you. 284.El 285.Sh AUTHORS 286.An "Johannes Maximilian Kuehn" 287.An "Harlan Stenn" 288.An "Dave Hart" 289.Sh "COPYRIGHT" 290Copyright (C) 1970\-2014 The University of Delaware all rights reserved. 291This program is released under the terms of the NTP license, <http://ntp.org/license>. 292.Sh "BUGS" 293Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org 294.Sh "NOTES" 295This manual page was \fIAutoGen\fP\-erated from the \fBsntp\fP 296option definitions. 297