sntp.1sntpmdoc revision 289997
1139826Simp.Dd October 21 2015 253541Sshin.Dt SNTP 1sntpmdoc User Commands 353541Sshin.Os 453541Sshin.\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc) 553541Sshin.\" 653541Sshin.\" It has been AutoGen-ed October 21, 2015 at 12:30:59 PM by AutoGen 5.18.5 753541Sshin.\" From the definitions sntp-opts.def 853541Sshin.\" and the template file agmdoc-cmd.tpl 953541Sshin.Sh NAME 1053541Sshin.Nm sntp 1153541Sshin.Nd standard Simple Network Time Protocol client program 1253541Sshin.Sh SYNOPSIS 1353541Sshin.Nm 1453541Sshin.\" Mixture of short (flag) options and long options 1553541Sshin.Op Fl flags 1653541Sshin.Op Fl flag Op Ar value 1753541Sshin.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc 1853541Sshin[ hostname\-or\-IP ...] 1953541Sshin.Pp 2053541Sshin.Sh DESCRIPTION 2153541Sshin.Nm 2253541Sshincan be used as an SNTP client to query a NTP or SNTP server and either display 2353541Sshinthe time or set the local system's time (given suitable privilege). It can be 2453541Sshinrun as an interactive command or from a 2553541Sshin.Ic cron 2653541Sshinjob. 2753541SshinNTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol) 28174510Sobrienare defined and described by RFC 5905. 29174510Sobrien.Pp 3053541SshinThe default is to write the estimated correct local date and time (i.e. not 3153541SshinUTC) to the standard output in a format like: 32174510Sobrien.Ic "'1996\-10\-15 20:17:25.123 (+0800) +4.567 +/\- 0.089 [host] IP sN'" 33174510Sobrienwhere the 34174510Sobrien.Ic "'(+0800)'" 3562587Sitojunmeans that to get to UTC from the reported local time one must 3662587Sitojunadd 8 hours and 0 minutes, 3762587Sitojunthe 3853541Sshin.Ic "'+4.567'" 3953541Sshinindicates the local clock is 4.567 seconds behind the correct time 4053541Sshin(so 4.567 seconds must be added to the local clock to get it to be correct). 4162587SitojunNote that the number of decimals printed for this value will change 4278064Sumebased on the reported precision of the server. 4353541Sshin.Ic "'+/\- 0.089'" 4453541Sshinis the reported 4553541Sshin.Em synchronization distance 4653541Sshin(in seconds), which represents the maximum error due to all causes. 4753541SshinIf the server does not report valid data needed to calculate the 4862587Sitojunsynchronization distance, this will be reported as 4953541Sshin.Ic "'+/\- ?'" . 50148385SumeIf the 5153541Sshin.Em host 5253541Sshinis different from the 5353541Sshin.Em IP , 54171259Sdelphijboth will be displayed. 55171259SdelphijOtherwise, only the 56171259Sdelphij.Em IP 57171259Sdelphijis displayed. 5853541SshinFinally, the 59171259Sdelphij.Em stratum 6053541Sshinof the host is reported 6178064Sumeand the leap indicator is decoded and displayed. 6278064Sume.Sh "OPTIONS" 6378064Sume.Bl -tag 6453541Sshin.It Fl 4 , Fl \-ipv4 65235954SbzForce IPv4 DNS name resolution. 66121673SumeThis option must not appear in combination with any of the following options: 6753541Sshinipv6. 68121673Sume.sp 69121673SumeForce DNS resolution of the following host names on the command line 7078064Sumeto the IPv4 namespace. 7178064Sume.It Fl 6 , Fl \-ipv6 72249294SaeForce IPv6 DNS name resolution. 7378064SumeThis option must not appear in combination with any of the following options: 7478064Sumeipv4. 7578064Sume.sp 7678064SumeForce DNS resolution of the following host names on the command line 77235954Sbzto the IPv6 namespace. 7878064Sume.It Fl a Ar auth\-keynumber , Fl \-authentication Ns = Ns Ar auth\-keynumber 7962587SitojunEnable authentication with the key \fBauth\-keynumber\fP. 8053541SshinThis option takes an integer number as its argument. 8153541Sshin.sp 8253541SshinEnable authentication using the key specified in this option's 8362587Sitojunargument. The argument of this option is the \fBkeyid\fP, a 8462587Sitojunnumber specified in the \fBkeyfile\fP as this key's identifier. 8562587SitojunSee the \fBkeyfile\fP option (\fB\-k\fP) for more details. 8662587Sitojun.It Fl b Ar broadcast\-address , Fl \-broadcast Ns = Ns Ar broadcast\-address 87249294SaeListen to the address specified for broadcast time sync. 8862587SitojunThis option may appear an unlimited number of times. 8962587Sitojun.sp 9062587SitojunIf specified \fBsntp\fP will listen to the specified address 9153541Sshinfor NTP broadcasts. The default maximum wait time 92189303Sbzcan (and probably should) be modified with \fB\-t\fP. 93189303Sbz.It Fl c Ar host\-name , Fl \-concurrent Ns = Ns Ar host\-name 94189303SbzConcurrently query all IPs returned for host\-name. 95189303SbzThis option may appear an unlimited number of times. 9662587Sitojun.sp 9762587SitojunRequests from an NTP "client" to a "server" should never be sent 98189303Sbzmore rapidly than one every 2 seconds. By default, any IPs returned 9962587Sitojunas part of a DNS lookup are assumed to be for a single instance of 10062587Sitojun\fBntpd\fP, and therefore \fBsntp\fP will send queries to these IPs 10162587Sitojunone after another, with a 2\-second gap in between each query. 10262587Sitojun.sp 103249294SaeThe \fB\-c\fP or \fB\-\-concurrent\fP flag says that any IPs 10462587Sitojunreturned for the DNS lookup of the supplied host\-name are on 10562587Sitojundifferent machines, so we can send concurrent queries. 106120856Sume.It Fl d , Fl \-debug\-level 10753541SshinIncrease debug verbosity level. 10853541SshinThis option may appear an unlimited number of times. 10953541Sshin.sp 110120856Sume.It Fl D Ar number , Fl \-set\-debug\-level Ns = Ns Ar number 11153541SshinSet 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. 141.sp 142This option specifies the keyfile. 143\fBsntp\fP will search for the key specified with \fB\-a\fP 144\fIkeyno\fP in this file. See \fBntp.keys(5)\fP for more 145information. 146.It Fl l Ar file\-name , Fl \-logfile Ns = Ns Ar file\-name 147Log to specified logfile. 148.sp 149This option causes the client to write log messages to the specified 150\fIlogfile\fP. 151.It Fl M Ar number , Fl \-steplimit Ns = Ns Ar number 152Adjustments less than \fBsteplimit\fP msec will be slewed. 153This option takes an integer number as its argument. 154The value of 155.Ar number 156is constrained to being: 157.in +4 158.nf 159.na 160greater than or equal to 0 161.fi 162.in -4 163.sp 164If the time adjustment is less than \fIsteplimit\fP milliseconds, 165slew the amount using \fBadjtime(2)\fP. Otherwise, step the 166correction using \fBsettimeofday(2)\fP. The default value is 0, 167which means all adjustments will be stepped. This is a feature, as 168different situations demand different values. 169.It Fl o Ar number , Fl \-ntpversion Ns = Ns Ar number 170Send \fBint\fP as our NTP protocol version. 171This option takes an integer number as its argument. 172The value of 173.Ar number 174is constrained to being: 175.in +4 176.nf 177.na 178in the range 0 through 7 179.fi 180.in -4 181The default 182.Ar number 183for this option is: 184.ti +4 185 4 186.sp 187When sending requests to a remote server, tell them we are running 188NTP protocol version \fIntpversion\fP . 189.It Fl r , Fl \-usereservedport 190Use the NTP Reserved Port (port 123). 191.sp 192Use port 123, which is reserved for NTP, for our network 193communications. 194.It Fl S , Fl \-step 195OK to 'step' the time with \fBsettimeofday(2)\fP. 196.sp 197.It Fl s , Fl \-slew 198OK to 'slew' the time with \fBadjtime(2)\fP. 199.sp 200.It Fl t Ar seconds , Fl \-timeout Ns = Ns Ar seconds 201The number of seconds to wait for responses. 202This option takes an integer number as its argument. 203The default 204.Ar seconds 205for this option is: 206.ti +4 207 5 208.sp 209When waiting for a reply, \fBsntp\fP will wait the number 210of seconds specified before giving up. The default should be 211more than enough for a unicast response. If \fBsntp\fP is 212only waiting for a broadcast response a longer timeout is 213likely needed. 214.It Fl \-wait , " Fl \-no\-wait" 215Wait for pending replies (if not setting the time). 216The \fIno\-wait\fP form will disable the option. 217This option is enabled by default. 218.sp 219If we are not setting the time, wait for all pending responses. 220.It Fl \&? , Fl \-help 221Display usage information and exit. 222.It Fl \&! , Fl \-more\-help 223Pass the extended usage information through a pager. 224.It Fl > Oo Ar cfgfile Oc , Fl \-save\-opts Oo Ns = Ns Ar cfgfile Oc 225Save the option state to \fIcfgfile\fP. The default is the \fIlast\fP 226configuration file listed in the \fBOPTION PRESETS\fP section, below. 227The command will exit after updating the config file. 228.It Fl < Ar cfgfile , Fl \-load\-opts Ns = Ns Ar cfgfile , Fl \-no\-load\-opts 229Load options from \fIcfgfile\fP. 230The \fIno\-load\-opts\fP form will disable the loading 231of earlier config/rc/ini files. \fI\-\-no\-load\-opts\fP is handled early, 232out of order. 233.It Fl \-version Op Brq Ar v|c|n 234Output version of program and exit. The default mode is `v', a simple 235version. The `c' mode will print copyright information and `n' will 236print the full copyright notice. 237.El 238.Sh "OPTION PRESETS" 239Any option that is not marked as \fInot presettable\fP may be preset 240by loading values from configuration ("RC" or ".INI") file(s) and values from 241environment variables named: 242.nf 243 \fBSNTP_<option\-name>\fP or \fBSNTP\fP 244.fi 245.ad 246The environmental presets take precedence (are processed later than) 247the configuration files. 248The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP". 249If any of these are directories, then the file \fI.ntprc\fP 250is searched for within those directories. 251.Sh USAGE 252.Bl -tag -width indent 253.It Li "sntp ntpserver.somewhere" 254is the simplest use of this program 255and can be run as an unprivileged command 256to check the current time and error in the local clock. 257.It Li "sntp \-Ss \-M 128 ntpserver.somewhere" 258With suitable privilege, 259run as a command 260or from a 261.Xr cron 8 262job, 263.Ic "sntp \-Ss \-M 128 ntpserver.somewhere" 264will request the time from the server, 265and if that server reports that it is synchronized 266then if the offset adjustment is less than 128 milliseconds 267the correction will be slewed, 268and if the correction is more than 128 milliseconds 269the correction will be stepped. 270.It Li "sntp \-S ntpserver.somewhere" 271With suitable privilege, 272run as a command 273or from a 274.Xr cron 8 275job, 276.Ic "sntp \-S ntpserver.somewhere" 277will set (step) the local clock from a synchronized specified server, 278like the (deprecated) 279.Xr ntpdate 1ntpdatemdoc , 280or 281.Xr rdate 8 282commands. 283.El 284.Sh "ENVIRONMENT" 285See \fBOPTION PRESETS\fP for configuration environment variables. 286.Sh "FILES" 287See \fBOPTION PRESETS\fP for configuration files. 288.Sh "EXIT STATUS" 289One of the following exit values will be returned: 290.Bl -tag 291.It 0 " (EXIT_SUCCESS)" 292Successful program execution. 293.It 1 " (EXIT_FAILURE)" 294The operation failed or the command syntax was not valid. 295.It 66 " (EX_NOINPUT)" 296A specified configuration file could not be loaded. 297.It 70 " (EX_SOFTWARE)" 298libopts had an internal operational error. Please report 299it to autogen\-users@lists.sourceforge.net. Thank you. 300.El 301.Sh AUTHORS 302.An "Johannes Maximilian Kuehn" 303.An "Harlan Stenn" 304.An "Dave Hart" 305.Sh "COPYRIGHT" 306Copyright (C) 1992\-2015 The University of Delaware and Network Time Foundation all rights reserved. 307This program is released under the terms of the NTP license, <http://ntp.org/license>. 308.Sh "BUGS" 309Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org 310.Sh "NOTES" 311This manual page was \fIAutoGen\fP\-erated from the \fBsntp\fP 312option definitions. 313