summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/sntp/invoke-sntp.texi
blob: ec2ff9a198bcefe938015bab0e76070e550b6be8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
@node sntp Invocation
@section Invoking sntp
@pindex sntp
@cindex standard Simple Network Time Protocol client program
@ignore
#
# EDIT THIS FILE WITH CAUTION  (invoke-sntp.texi)
#
# It has been AutoGen-ed  March 21, 2017 at 10:36:49 AM by AutoGen 5.18.5
# From the definitions    sntp-opts.def
# and the template file   agtexi-cmd.tpl
@end ignore



@code{sntp}
can be used as an SNTP client to query a NTP or SNTP server and either display
the time or set the local system's time (given suitable privilege).  It can be
run as an interactive command or from a
@code{cron}
job.

NTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol)
are defined and described by RFC 5905.


The default is to write the estimated correct local date and time (i.e. not
UTC) to the standard output in a format like:

@code{'1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN'}

where the
@code{'(+0800)'}
means that to get to UTC from the reported local time one must
add 8 hours and 0 minutes,
the
@code{'+4.567'}
indicates the local clock is 4.567 seconds behind the correct time
(so 4.567 seconds must be added to the local clock to get it to be correct).
Note that the number of decimals printed for this value will change
based on the reported precision of the server.
@code{'+/- 0.089'}
is the reported
@emph{synchronization} @emph{distance}
(in seconds), which represents the maximum error due to all causes.
If the server does not report valid data needed to calculate the
synchronization distance, this will be reported as
@code{'+/- ?'}.
If the
@emph{host}
is different from the
@emph{IP},
both will be displayed.
Otherwise, only the 
@emph{IP}
is displayed.
Finally, the
@emph{stratum}
of the host is reported
and the leap indicator is decoded and displayed.

This section was generated by @strong{AutoGen},
using the @code{agtexi-cmd} template and the option descriptions for the @code{sntp} program.
This software is released under the NTP license, <http://ntp.org/license>.

@menu
* sntp usage::                  sntp help/usage (@option{--help})
* sntp ipv4::                   ipv4 option (-4)
* sntp ipv6::                   ipv6 option (-6)
* sntp authentication::         authentication option (-a)
* sntp broadcast::              broadcast option (-b)
* sntp concurrent::             concurrent option (-c)
* sntp gap::                    gap option (-g)
* sntp kod::                    kod option (-K)
* sntp keyfile::                keyfile option (-k)
* sntp logfile::                logfile option (-l)
* sntp steplimit::              steplimit option (-M)
* sntp ntpversion::             ntpversion option (-o)
* sntp usereservedport::        usereservedport option (-r)
* sntp timeout::                timeout option (-t)
* sntp wait::                   wait option
* sntp config::                 presetting/configuring sntp
* sntp exit status::            exit status
* sntp Usage::                  Usage
* sntp Authors::                Authors
@end menu

@node sntp usage
@subsection sntp help/usage (@option{--help})
@cindex sntp help

This is the automatically generated usage text for sntp.

The text printed is the same whether selected with the @code{help} option
(@option{--help}) or the @code{more-help} option (@option{--more-help}).  @code{more-help} will print
the usage text by passing it through a pager program.
@code{more-help} is disabled on platforms without a working
@code{fork(2)} function.  The @code{PAGER} environment variable is
used to select the program, defaulting to @file{more}.  Both will exit
with a status code of 0.

@exampleindent 0
@example
sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p10
Usage:  sntp [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
                [ hostname-or-IP ...]
  Flg Arg Option-Name    Description
   -4 no  ipv4           Force IPv4 DNS name resolution
                                - prohibits the option 'ipv6'
   -6 no  ipv6           Force IPv6 DNS name resolution
                                - prohibits the option 'ipv4'
   -a Num authentication Enable authentication with the key auth-keynumber
   -b Str broadcast      Listen to the address specified for broadcast time sync
                                - may appear multiple times
   -c Str concurrent     Concurrently query all IPs returned for host-name
                                - may appear multiple times
   -d no  debug-level    Increase debug verbosity level
                                - may appear multiple times
   -D Num set-debug-level Set the debug verbosity level
                                - may appear multiple times
   -g Num gap            The gap (in milliseconds) between time requests
   -K Fil kod            KoD history filename
   -k Fil keyfile        Look in this file for the key specified with -a
   -l Fil logfile        Log to specified logfile
   -M Num steplimit      Adjustments less than steplimit msec will be slewed
                                - it must be in the range:
                                  greater than or equal to 0
   -o Num ntpversion     Send int as our NTP protocol version
                                - it must be in the range:
                                  0 to 7
   -r no  usereservedport Use the NTP Reserved Port (port 123)
   -S no  step           OK to 'step' the time with settimeofday(2)
   -s no  slew           OK to 'slew' the time with adjtime(2)
   -t Num timeout        The number of seconds to wait for responses
      no  wait           Wait for pending replies (if not setting the time)
                                - disabled as '--no-wait'
                                - enabled by default
      opt version        output version information and exit
   -? no  help           display extended usage information and exit
   -! no  more-help      extended usage information passed thru pager
   -> opt save-opts      save the option state to a config file
   -< Str load-opts      load options from a config file
                                - disabled as '--no-load-opts'
                                - may appear multiple times

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.


The following option preset mechanisms are supported:
 - reading file $HOME/.ntprc
 - reading file ./.ntprc
 - examining environment variables named SNTP_*

Please send bug reports to:  <http://bugs.ntp.org, bugs@@ntp.org>
@end example
@exampleindent 4

@node sntp ipv4
@subsection ipv4 option (-4)
@cindex sntp-ipv4

This is the ``force ipv4 dns name resolution'' option.

@noindent
This option has some usage constraints.  It:
@itemize @bullet
@item
must not appear in combination with any of the following options:
ipv6.
@end itemize

Force DNS resolution of the following host names on the command line
to the IPv4 namespace.
@node sntp ipv6
@subsection ipv6 option (-6)
@cindex sntp-ipv6

This is the ``force ipv6 dns name resolution'' option.

@noindent
This option has some usage constraints.  It:
@itemize @bullet
@item
must not appear in combination with any of the following options:
ipv4.
@end itemize

Force DNS resolution of the following host names on the command line
to the IPv6 namespace.
@node sntp authentication
@subsection authentication option (-a)
@cindex sntp-authentication

This is the ``enable authentication with the key @var{auth-keynumber}'' option.
This option takes a number argument @file{auth-keynumber}.
Enable authentication using the key specified in this option's
argument.  The argument of this option is the @option{keyid}, a
number specified in the @option{keyfile} as this key's identifier.
See the @option{keyfile} option (@option{-k}) for more details.
@node sntp broadcast
@subsection broadcast option (-b)
@cindex sntp-broadcast

This is the ``listen to the address specified for broadcast time sync'' option.
This option takes a string argument @file{broadcast-address}.

@noindent
This option has some usage constraints.  It:
@itemize @bullet
@item
may appear an unlimited number of times.
@end itemize

If specified @code{sntp} will listen to the specified address
for NTP broadcasts.  The default maximum wait time
can (and probably should) be modified with @option{-t}.
@node sntp concurrent
@subsection concurrent option (-c)
@cindex sntp-concurrent

This is the ``concurrently query all ips returned for host-name'' option.
This option takes a string argument @file{host-name}.

@noindent
This option has some usage constraints.  It:
@itemize @bullet
@item
may appear an unlimited number of times.
@end itemize

Requests from an NTP "client" to a "server" should never be sent
more rapidly than one every 2 seconds.  By default, any IPs returned
as part of a DNS lookup are assumed to be for a single instance of
@code{ntpd}, and therefore @code{sntp} will send queries to these IPs
one after another, with a 2-second gap in between each query.

The @option{-c} or @option{--concurrent} flag says that any IPs
returned for the DNS lookup of the supplied host-name are on
different machines, so we can send concurrent queries.
@node sntp gap
@subsection gap option (-g)
@cindex sntp-gap

This is the ``the gap (in milliseconds) between time requests'' option.
This option takes a number argument @file{milliseconds}.
Since we're only going to use the first valid response we get and
there is benefit to specifying a good number of servers to query,
separate the queries we send out by the specified number of
milliseconds.
@node sntp kod
@subsection kod option (-K)
@cindex sntp-kod

This is the ``kod history filename'' option.
This option takes a file argument @file{file-name}.
Specifies the filename to be used for the persistent history of KoD
responses received from servers.  If the file does not exist, a
warning message will be displayed.  The file will not be created.
@node sntp keyfile
@subsection keyfile option (-k)
@cindex sntp-keyfile

This is the ``look in this file for the key specified with @option{-a}'' option.
This option takes a file argument @file{file-name}.
This option specifies the keyfile.
@code{sntp} will search for the key specified with @option{-a}
@file{keyno} in this file.  See @command{ntp.keys(5)} for more
information.
@node sntp logfile
@subsection logfile option (-l)
@cindex sntp-logfile

This is the ``log to specified logfile'' option.
This option takes a file argument @file{file-name}.
This option causes the client to write log messages to the specified
@file{logfile}.
@node sntp steplimit
@subsection steplimit option (-M)
@cindex sntp-steplimit

This is the ``adjustments less than @var{steplimit} msec will be slewed'' option.
This option takes a number argument.
If the time adjustment is less than @file{steplimit} milliseconds,
slew the amount using @command{adjtime(2)}.  Otherwise, step the
correction using @command{settimeofday(2)}.  The default value is 0,
which means all adjustments will be stepped.  This is a feature, as
different situations demand different values.
@node sntp ntpversion
@subsection ntpversion option (-o)
@cindex sntp-ntpversion

This is the ``send @var{int} as our ntp protocol version'' option.
This option takes a number argument.
When sending requests to a remote server, tell them we are running
NTP protocol version @file{ntpversion} .
@node sntp usereservedport
@subsection usereservedport option (-r)
@cindex sntp-usereservedport

This is the ``use the ntp reserved port (port 123)'' option.
Use port 123, which is reserved for NTP, for our network
communications.
@node sntp timeout
@subsection timeout option (-t)
@cindex sntp-timeout

This is the ``the number of seconds to wait for responses'' option.
This option takes a number argument @file{seconds}.
When waiting for a reply, @code{sntp} will wait the number
of seconds specified before giving up.  The default should be
more than enough for a unicast response.  If @code{sntp} is
only waiting for a broadcast response a longer timeout is
likely needed.
@node sntp wait
@subsection wait option
@cindex sntp-wait

This is the ``wait for pending replies (if not setting the time)'' option.

@noindent
This option has some usage constraints.  It:
@itemize @bullet
@item
can be disabled with --no-wait.
@item
It is enabled by default.
@end itemize

If we are not setting the time, wait for all pending responses.


@node sntp config
@subsection presetting/configuring sntp

Any option that is not marked as @i{not presettable} may be preset by
loading values from configuration ("rc" or "ini") files, and values from environment variables named @code{SNTP} and @code{SNTP_<OPTION_NAME>}.  @code{<OPTION_NAME>} must be one of
the options listed above in upper case and segmented with underscores.
The @code{SNTP} variable will be tokenized and parsed like
the command line.  The remaining variables are tested for existence and their
values are treated like option arguments.


@noindent
@code{libopts} will search in 2 places for configuration files:
@itemize @bullet
@item
$HOME
@item
$PWD
@end itemize
The environment variables @code{HOME}, and @code{PWD}
are expanded and replaced when @file{sntp} runs.
For any of these that are plain files, they are simply processed.
For any that are directories, then a file named @file{.ntprc} is searched for
within that directory and processed.

Configuration files may be in a wide variety of formats.
The basic format is an option name followed by a value (argument) on the
same line.  Values may be separated from the option name with a colon,
equal sign or simply white space.  Values may be continued across multiple
lines by escaping the newline with a backslash.

Multiple programs may also share the same initialization file.
Common options are collected at the top, followed by program specific
segments.  The segments are separated by lines like:
@example
[SNTP]
@end example
@noindent
or by
@example
<?program sntp>
@end example
@noindent
Do not mix these styles within one configuration file.

Compound values and carefully constructed string values may also be
specified using XML syntax:
@example
<option-name>
   <sub-opt>...&lt;...&gt;...</sub-opt>
</option-name>
@end example
@noindent
yielding an @code{option-name.sub-opt} string value of
@example
"...<...>..."
@end example
@code{AutoOpts} does not track suboptions.  You simply note that it is a
hierarchicly valued option.  @code{AutoOpts} does provide a means for searching
the associated name/value pair list (see: optionFindValue).

The command line options relating to configuration and/or usage help are:

@subsubheading version (-)

Print the program version to standard out, optionally with licensing
information, then exit 0.  The optional argument specifies how much licensing
detail to provide.  The default is to print just the version.  The licensing infomation may be selected with an option argument.
Only the first letter of the argument is examined:

@table @samp
@item version
Only print the version.  This is the default.
@item copyright
Name the copyright usage licensing terms.
@item verbose
Print the full copyright usage licensing terms.
@end table

@node sntp exit status
@subsection sntp exit status

One of the following exit values will be returned:
@table @samp
@item 0 (EXIT_SUCCESS)
Successful program execution.
@item 1 (EXIT_FAILURE)
The operation failed or the command syntax was not valid.
@item 66 (EX_NOINPUT)
A specified configuration file could not be loaded.
@item 70 (EX_SOFTWARE)
libopts had an internal operational error.  Please report
it to autogen-users@@lists.sourceforge.net.  Thank you.
@end table
@node sntp Usage
@subsection sntp Usage
@node sntp Authors
@subsection sntp Authors
OpenPOWER on IntegriCloud