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