xref: /freebsd/contrib/ntp/sntp/sntp.mdoc.in (revision 5b9c547c)
1.Dd February 4 2015
2.Dt SNTP @SNTP_MS@ User Commands
3.Os
4.\"  EDIT THIS FILE WITH CAUTION  (sntp-opts.mdoc)
5.\"
6.\"  It has been AutoGen-ed  February  4, 2015 at 02:34:20 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.  The default value is 0,
166which means all adjustments will be stepped.  This is a feature, as
167different situations demand different values.
168.It  Fl o Ar number , Fl \-ntpversion Ns = Ns Ar number
169Send \fBint\fP as our NTP protocol version.
170This option takes an integer number as its argument.
171The value of
172.Ar number
173is constrained to being:
174.in +4
175.nf
176.na
177in the range  0 through 7
178.fi
179.in -4
180The default
181.Ar number
182for this option is:
183.ti +4
184 4
185.sp
186When sending requests to a remote server, tell them we are running
187NTP protocol version \fIntpversion\fP .
188.It  Fl r , Fl \-usereservedport
189Use the NTP Reserved Port (port 123).
190.sp
191Use port 123, which is reserved for NTP, for our network
192communications.
193.It  Fl S , Fl \-step
194OK to 'step' the time with \fBsettimeofday(2)\fP.
195.sp
196.It  Fl s , Fl \-slew
197OK to 'slew' the time with \fBadjtime(2)\fP.
198.sp
199.It  Fl t Ar seconds , Fl \-timeout Ns = Ns Ar seconds
200The number of seconds to wait for responses.
201This option takes an integer number as its argument.
202The default
203.Ar seconds
204for this option is:
205.ti +4
206 5
207.sp
208When waiting for a reply, \fBsntp\fP will wait the number
209of seconds specified before giving up.  The default should be
210more than enough for a unicast response.  If \fBsntp\fP is
211only waiting for a broadcast response a longer timeout is
212likely needed.
213.It  Fl \-wait , " Fl \-no\-wait"
214Wait for pending replies (if not setting the time).
215The \fIno\-wait\fP form will disable the option.
216This option is enabled by default.
217.sp
218If we are not setting the time, wait for all pending responses.
219.It Fl \&? , Fl \-help
220Display usage information and exit.
221.It Fl \&! , Fl \-more\-help
222Pass the extended usage information through a pager.
223.It Fl > Oo Ar cfgfile Oc , Fl \-save\-opts Oo Ns = Ns Ar cfgfile Oc
224Save the option state to \fIcfgfile\fP.  The default is the \fIlast\fP
225configuration file listed in the \fBOPTION PRESETS\fP section, below.
226The command will exit after updating the config file.
227.It Fl < Ar cfgfile , Fl \-load\-opts Ns = Ns Ar cfgfile , Fl \-no\-load\-opts
228Load options from \fIcfgfile\fP.
229The \fIno\-load\-opts\fP form will disable the loading
230of earlier config/rc/ini files.  \fI\-\-no\-load\-opts\fP is handled early,
231out of order.
232.It Fl \-version Op Brq Ar v|c|n
233Output version of program and exit.  The default mode is `v', a simple
234version.  The `c' mode will print copyright information and `n' will
235print the full copyright notice.
236.El
237.Sh "OPTION PRESETS"
238Any option that is not marked as \fInot presettable\fP may be preset
239by loading values from configuration ("RC" or ".INI") file(s) and values from
240environment variables named:
241.nf
242  \fBSNTP_<option\-name>\fP or \fBSNTP\fP
243.fi
244.ad
245The environmental presets take precedence (are processed later than)
246the configuration files.
247The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
248If any of these are directories, then the file \fI.ntprc\fP
249is searched for within those directories.
250.Sh USAGE
251.Bl -tag -width indent
252.It Li "sntp ntpserver.somewhere"
253is the simplest use of this program
254and can be run as an unprivileged command
255to check the current time and error in the local clock.
256.It Li "sntp \-Ss \-M 128 ntpserver.somewhere"
257With suitable privilege,
258run as a command
259or from a
260.Xr cron 8
261job,
262.Ic "sntp \-Ss \-M 128 ntpserver.somewhere"
263will request the time from the server,
264and if that server reports that it is synchronized
265then if the offset adjustment is less than 128 milliseconds
266the correction will be slewed,
267and if the correction is more than 128 milliseconds
268the correction  will be stepped.
269.It Li "sntp \-S ntpserver.somewhere"
270With suitable privilege,
271run as a command
272or from a
273.Xr cron 8
274job,
275.Ic "sntp \-S ntpserver.somewhere"
276will set (step) the local clock from a synchronized specified server,
277like the (deprecated)
278.Xr ntpdate @NTPDATE_MS@ ,
279or
280.Xr rdate 8
281commands.
282.El
283.Sh "ENVIRONMENT"
284See \fBOPTION PRESETS\fP for configuration environment variables.
285.Sh "FILES"
286See \fBOPTION PRESETS\fP for configuration files.
287.Sh "EXIT STATUS"
288One of the following exit values will be returned:
289.Bl -tag
290.It 0 " (EXIT_SUCCESS)"
291Successful program execution.
292.It 1 " (EXIT_FAILURE)"
293The operation failed or the command syntax was not valid.
294.It 66 " (EX_NOINPUT)"
295A specified configuration file could not be loaded.
296.It 70 " (EX_SOFTWARE)"
297libopts had an internal operational error.  Please report
298it to autogen\-users@lists.sourceforge.net.  Thank you.
299.El
300.Sh AUTHORS
301.An "Johannes Maximilian Kuehn"
302.An "Harlan Stenn"
303.An "Dave Hart"
304.Sh "COPYRIGHT"
305Copyright (C) 1992\-2015 The University of Delaware and Network Time Foundation all rights reserved.
306This program is released under the terms of the NTP license, <http://ntp.org/license>.
307.Sh "BUGS"
308Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
309.Sh "NOTES"
310This manual page was \fIAutoGen\fP\-erated from the \fBsntp\fP
311option definitions.
312