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