aboutsummaryrefslogtreecommitdiff
path: root/sntp/sntp.html
blob: b043f407b22d852bb335de4042b3f527528f5f34 (plain) (blame)
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<html lang="en">
<head>
<title>Sntp User's Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Sntp User's Manual">
<meta name="generator" content="makeinfo 4.7">
<link title="Top" rel="top" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc { font-variant:small-caps }
  span.roman { font-family: serif; font-weight: normal; } 
--></style>
</head>
<body>
<h1 class="settitle">Sntp User's Manual</h1>
<div class="node">
<p><hr>
<a name="Top"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-Description">sntp Description</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<br>
</div>

<h2 class="unnumbered">Simple Network Time Protocol User Manual</h2>

<p>This document describes the use of the NTP Project's <code>sntp</code> program,
that can be used to query a Network Time Protocol (NTP) server and
display the time offset of the system clock relative to the server
clock.  Run as root, it can correct the system clock to this offset as
well.  It can be run as an interactive command or from a cron job.

  <p>This document applies to version 4.2.6p5 of <code>sntp</code>.

  <p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
IETF specification.

  <div class="shortcontents">
<h2>Short Contents</h2>
<ul>
<a href="#Top">Simple Network Time Protocol User Manual</a>
</ul>
</div>

<ul class="menu">
<li><a accesskey="1" href="#sntp-Description">sntp Description</a>:             Description
<li><a accesskey="2" href="#sntp-Invocation">sntp Invocation</a>: 		Invoking sntp
<li><a accesskey="3" href="#Usage">Usage</a>:                        Usage
</ul>

<div class="node">
<p><hr>
<a name="sntp-Description"></a>
<br>
</div>

<!-- node-name,  next,  previous,  up -->
<h3 class="section">Description</h3>

<p>By default, <code>sntp</code> writes the local data and time (i.e., not UTC) to the
standard output in the format:

<pre class="example">     1996 Oct 15 20:17:25.123 +4.567 +/- 0.089 secs
</pre>
  <p>where the +4.567 +/- 0.089 secs indicates the time offset and
error bound of the system clock relative to the server clock.

<div class="node">
<p><hr>
<a name="sntp-Invocation"></a>
<br>
</div>

<h3 class="section">Invoking sntp</h3>

<p><a name="index-sntp-1"></a><a name="index-standard-Simple-Network-Time-Protocol-program-2"></a>
<code>sntp</code>
can be used as a 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 in a
<code>cron</code>
job.

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

  <p class="indent">The default is to write the estimated correct local date and time (i.e. not
UTC) to the standard output in a format like
<pre class="example">     1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 secs
</pre>
  <p>where the
<pre class="example">     +4.567 +/- 0.089 secs
</pre>
  <p>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),
and the (local) time of
<code>1996-10-15 20:17:25.123</code>
can be converted to UTC time by adding 8 hours and 0 minutes, and
is believed to be correct to within
<code>+/- 0.089</code>
seconds.

  <p>This section was generated by <strong>AutoGen</strong>,
the aginfo template and the option descriptions for the <span class="command">sntp</span> program.  It documents the <span class="command">sntp</span> usage text and option meanings.

  <p>This software is released under a specialized copyright license.

<ul class="menu">
<li><a accesskey="1" href="#sntp-usage">sntp usage</a>:                   sntp usage help (-?) 
<li><a accesskey="2" href="#sntp-adjtime">sntp adjtime</a>:                adjtime option (-j)
<li><a accesskey="3" href="#sntp-authentication">sntp authentication</a>:         authentication option (-a)
<li><a accesskey="4" href="#sntp-broadcast">sntp broadcast</a>:              broadcast option (-b)
<li><a accesskey="5" href="#sntp-ipv4">sntp ipv4</a>:                   ipv4 option (-4)
<li><a accesskey="6" href="#sntp-ipv6">sntp ipv6</a>:                   ipv6 option (-6)
<li><a accesskey="7" href="#sntp-keyfile">sntp keyfile</a>:                keyfile option (-k)
<li><a accesskey="8" href="#sntp-kod">sntp kod</a>:                    kod option (-K)
<li><a accesskey="9" href="#sntp-logfile">sntp logfile</a>:                logfile option (-l)
<li><a href="#sntp-normalverbose">sntp normalverbose</a>:          normalverbose option (-d)
<li><a href="#sntp-settod">sntp settod</a>:                 settod option (-s)
<li><a href="#sntp-syslog">sntp syslog</a>:                 syslog option (-p)
<li><a href="#sntp-timeout">sntp timeout</a>:                timeout option (-t)
</ul>

<div class="node">
<p><hr>
<a name="sntp-usage"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-adjtime">sntp adjtime</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">sntp usage help (-?)</h4>

<p><a name="index-sntp-usage-3"></a>
This is the automatically generated usage text for sntp:

<pre class="example">sntp - standard Simple Network Time Protocol program - Ver. 4.2.6p5
USAGE:  sntp [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
                [ hostname-or-IP ...]
  Flg Arg Option-Name    Description
   -4 no  ipv4           Force IPv4 DNS name resolution
                                - prohibits these options:
                                ipv6
   -6 no  ipv6           Force IPv6 DNS name resolution
                                - prohibits these options:
                                ipv4
   -d no  normalverbose  Normal verbose
   -K Str kod            KoD history filename
   -p no  syslog         Logging with syslog
                                - prohibits these options:
                                logfile
   -l Str logfile        Log to specified logfile
                                - prohibits these options:
                                syslog
   -s no  settod         Set (step) the time with settimeofday()
                                - prohibits these options:
                                adjtime
   -j no  adjtime        Set (slew) the time with adjtime()
                                - prohibits these options:
                                settod
   -b Str broadcast      Use broadcasts to the address specified for synchronisation
   -t Num timeout        Specify the number of seconds to wait for broadcasts
   -a Num authentication Enable authentication with the key auth-keynumber
   -k Str keyfile        Specify a keyfile. SNTP will look in this file for the key specified with -a
      opt version        Output version information and exit
   -? no  help           Display extended usage information and exit
   -! no  more-help      Extended usage information passed thru pager
   -&gt; opt save-opts      Save the option state to a config file
   -&lt; 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_*

sntp implements the Simple Network Time Protocol, and is used to query an
NTP or SNTP server and either display the time or set the local system's
time (given suitable privilege).

It can be run interactively from the command line or as a cron job.

NTP and SNTP are defined by RFC 5905, which obsoletes RFC 4330 and RFC
1305.

please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
</pre>
  <div class="node">
<p><hr>
<a name="sntp-adjtime"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-authentication">sntp authentication</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-usage">sntp usage</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">adjtime option (-j)</h4>

<p><a name="index-sntp_002dadjtime-4"></a>
This is the &ldquo;set (slew) the time with adjtime()&rdquo; option.

  <p>This option has some usage constraints.  It:
     <ul>
<li>must not appear in combination with any of the following options:
settod. 
</ul>

<div class="node">
<p><hr>
<a name="sntp-authentication"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-broadcast">sntp broadcast</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-adjtime">sntp adjtime</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">authentication option (-a)</h4>

<p><a name="index-sntp_002dauthentication-5"></a>
This is the &ldquo;enable authentication with the key auth-keynumber&rdquo; option. 
This option enables authentication using the key specified in this option's argument. 
The argument of this option is the keyid, a number specified in the keyfile as this
key's identifier. See the keyfile option (-k) for more details.

<div class="node">
<p><hr>
<a name="sntp-broadcast"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-ipv4">sntp ipv4</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-authentication">sntp authentication</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">broadcast option (-b)</h4>

<p><a name="index-sntp_002dbroadcast-6"></a>
This is the &ldquo;use broadcasts to the address specified for synchronisation&rdquo; option. 
If specified SNTP will listen to the specified broadcast address
for NTP broadcasts.  The default maximum wait time,
68 seconds, can be modified with -t.

<div class="node">
<p><hr>
<a name="sntp-ipv4"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-ipv6">sntp ipv6</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-broadcast">sntp broadcast</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">ipv4 option (-4)</h4>

<p><a name="index-sntp_002dipv4-7"></a>
This is the &ldquo;force ipv4 dns name resolution&rdquo; option.

  <p>This option has some usage constraints.  It:
     <ul>
<li>must not appear in combination with any of the following options:
ipv6. 
</ul>

  <p>Force DNS resolution of the following host names on the command line
to the IPv4 namespace.

<div class="node">
<p><hr>
<a name="sntp-ipv6"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-keyfile">sntp keyfile</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-ipv4">sntp ipv4</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">ipv6 option (-6)</h4>

<p><a name="index-sntp_002dipv6-8"></a>
This is the &ldquo;force ipv6 dns name resolution&rdquo; option.

  <p>This option has some usage constraints.  It:
     <ul>
<li>must not appear in combination with any of the following options:
ipv4. 
</ul>

  <p>Force DNS resolution of the following host names on the command line
to the IPv6 namespace.

<div class="node">
<p><hr>
<a name="sntp-keyfile"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-kod">sntp kod</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-ipv6">sntp ipv6</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">keyfile option (-k)</h4>

<p><a name="index-sntp_002dkeyfile-9"></a>
This is the &ldquo;specify a keyfile. sntp will look in this file for the key specified with -a&rdquo; option. 
This option specifies the keyfile. SNTP will search for the key specified with -a keyno in this
file. Key files follow the following format:

  <p>keyid keytype key

  <p>Where	keyid is a number identifying this key
keytype is one of the follow:
S  Key in 64 Bit hexadecimal number as specified in in the DES specification. 
N  Key in 64 Bit hexadecimal number as specified in the NTP standard. 
A  Key in a 1-to-8 character ASCII string. 
M  Key in a 1-to-8 character ASCII string using the MD5 authentication scheme.

  <p>For more information see ntp.keys(5).

<div class="node">
<p><hr>
<a name="sntp-kod"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-logfile">sntp logfile</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-keyfile">sntp keyfile</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">kod option (-K)</h4>

<p><a name="index-sntp_002dkod-10"></a>
This is the &ldquo;kod history filename&rdquo; option. 
Specifies the filename to be used to persist the history of KoD
responses received from servers.  The default is
/var/db/ntp-kod.

<div class="node">
<p><hr>
<a name="sntp-logfile"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-normalverbose">sntp normalverbose</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-kod">sntp kod</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">logfile option (-l)</h4>

<p><a name="index-sntp_002dlogfile-11"></a>
This is the &ldquo;log to specified logfile&rdquo; option.

  <p>This option has some usage constraints.  It:
     <ul>
<li>must not appear in combination with any of the following options:
syslog. 
</ul>

  <p>This option causes the client to write log messages to the specified
logfile.

<div class="node">
<p><hr>
<a name="sntp-normalverbose"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-settod">sntp settod</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-logfile">sntp logfile</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">normalverbose option (-d)</h4>

<p><a name="index-sntp_002dnormalverbose-12"></a>
This is the &ldquo;normal verbose&rdquo; option. 
Diagnostic messages for non-fatal errors and a limited amount of
tracing should be written to standard error.  Fatal ones always
produce a diagnostic.  This option should be set when there is a
suspected problem with the server, network or the source.

<div class="node">
<p><hr>
<a name="sntp-settod"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-syslog">sntp syslog</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-normalverbose">sntp normalverbose</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">settod option (-s)</h4>

<p><a name="index-sntp_002dsettod-13"></a>
This is the &ldquo;set (step) the time with settimeofday()&rdquo; option.

  <p>This option has some usage constraints.  It:
     <ul>
<li>must not appear in combination with any of the following options:
adjtime. 
</ul>

<div class="node">
<p><hr>
<a name="sntp-syslog"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-timeout">sntp timeout</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-settod">sntp settod</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">syslog option (-p)</h4>

<p><a name="index-sntp_002dsyslog-14"></a>
This is the &ldquo;logging with syslog&rdquo; option.

  <p>This option has some usage constraints.  It:
     <ul>
<li>must not appear in combination with any of the following options:
logfile. 
</ul>

  <p>When this option is set all logging will be done using syslog.

<div class="node">
<p><hr>
<a name="sntp-timeout"></a>Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-syslog">sntp syslog</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>

<h4 class="subsection">timeout option (-t)</h4>

<p><a name="index-sntp_002dtimeout-15"></a>
This is the &ldquo;specify the number of seconds to wait for broadcasts&rdquo; option. 
When waiting for a broadcast packet SNTP will wait the number
of seconds specified before giving up.  Default 68 seconds.

<div class="node">
<p><hr>
<a name="Usage"></a>
<br>
</div>

<!-- node-name,  next,  previous,  up -->
<h3 class="section">Usage</h3>

<p>The simplest use of this program is as an unprivileged command to
check the current time, offset, and error in the local clock. 
For example:

<pre class="example">    sntp ntpserver.somewhere
</pre>
  <p>With suitable privilege, it can be run as a command or in a
<code>crom</code> job to reset the local clock from a reliable server, like
the <code>ntpdate</code> and <code>rdate</code> commands. 
For example:

<pre class="example">    sntp -a ntpserver.somewhere
</pre>
  </body></html>