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