xref: /freebsd/contrib/ntp/sntp/sntp.html (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Created by GNU Texinfo 6.6, http://www.gnu.org/software/texinfo/ -->
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6<title>Sntp User&rsquo;s Manual</title>
7
8<meta name="description" content="Sntp User&rsquo;s Manual">
9<meta name="keywords" content="Sntp User&rsquo;s Manual">
10<meta name="resource-type" content="document">
11<meta name="distribution" content="global">
12<meta name="Generator" content="makeinfo">
13<link href="#Top" rel="start" title="Top">
14<link href="dir.html#Top" rel="up" title="(dir)">
15<style type="text/css">
16<!--
17a.summary-letter {text-decoration: none}
18blockquote.indentedblock {margin-right: 0em}
19div.display {margin-left: 3.2em}
20div.example {margin-left: 3.2em}
21div.lisp {margin-left: 3.2em}
22kbd {font-style: oblique}
23pre.display {font-family: inherit}
24pre.format {font-family: inherit}
25pre.menu-comment {font-family: serif}
26pre.menu-preformatted {font-family: serif}
27span.nolinebreak {white-space: nowrap}
28span.roman {font-family: initial; font-weight: normal}
29span.sansserif {font-family: sans-serif; font-weight: normal}
30ul.no-bullet {list-style: none}
31-->
32</style>
33
34
35</head>
36
37<body lang="en">
38<h1 class="settitle" align="center">Sntp User&rsquo;s Manual</h1>
39
40
41
42
43
44<span id="Top"></span><div class="header">
45<p>
46Next: <a href="#sntp-Description" accesskey="n" rel="next">sntp Description</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> &nbsp; </p>
47</div>
48<span id="Simple-Network-Time-Protocol-User-Manual"></span><h1 class="top">Simple Network Time Protocol User Manual</h1>
49
50<p>This document describes the use of the NTP Project&rsquo;s <code>sntp</code> program,
51that can be used to query a Network Time Protocol (NTP) server and
52display the time offset of the system clock relative to the server
53clock.  Run as root, it can correct the system clock to this offset as
54well.  It can be run as an interactive command or from a cron job.
55</p>
56<p>This document applies to version 4.2.8p17 of <code>sntp</code>.
57</p>
58<p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
59IETF specification.
60</p>
61<span id="SEC_Overview"></span>
62<h2 class="shortcontents-heading">Short Table of Contents</h2>
63
64<div class="shortcontents">
65<ul class="no-bullet">
66<li><a id="stoc-Description" href="#toc-Description">1 Description</a></li>
67</ul>
68</div>
69
70
71<table class="menu" border="0" cellspacing="0">
72<tr><td align="left" valign="top">&bull; <a href="#sntp-Description" accesskey="1">sntp Description</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Description
73</td></tr>
74<tr><td align="left" valign="top">&bull; <a href="#sntp-Invocation" accesskey="2">sntp Invocation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Invoking sntp
75</td></tr>
76<tr><td align="left" valign="top">&bull; <a href="#Usage" accesskey="3">Usage</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Usage
77</td></tr>
78</table>
79
80<hr>
81<span id="sntp-Description"></span><div class="header">
82<p>
83Next: <a href="#sntp-Invocation" accesskey="n" rel="next">sntp Invocation</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; </p>
84</div>
85<span id="Description"></span><h2 class="chapter">1 Description</h2>
86
87<p>By default, <code>sntp</code> writes the local data and time (i.e., not UTC) to the
88standard output in the format:
89</p>
90<div class="example">
91<pre class="example">1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 secs
92</pre></div>
93
94<p>where
95YYYY-MM-DD HH:MM:SS.SUBSEC is the local date and time,
96(+0800) is the local timezone adjustment (so we would add 8 hours and 0 minutes to convert the reported local time to UTC),
97and
98the +4.567 +/- 0.089 secs indicates the time offset and
99error bound of the system clock relative to the server clock.
100</p>
101<table class="menu" border="0" cellspacing="0">
102<tr><td align="left" valign="top">&bull; <a href="#sntp-Invocation" accesskey="1">Invoking sntp</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
103</td></tr>
104<tr><td align="left" valign="top">&bull; <a href="#Usage" accesskey="2">Usage</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
105</td></tr>
106</table>
107
108<hr>
109<span id="sntp-Invocation"></span><div class="header">
110<p>
111Next: <a href="#Usage" accesskey="n" rel="next">Usage</a>, Previous: <a href="#sntp-Description" accesskey="p" rel="prev">sntp Description</a>, Up: <a href="#sntp-Description" accesskey="u" rel="up">sntp Description</a> &nbsp; </p>
112</div>
113<span id="Invoking-sntp"></span><h3 class="section">1.1 Invoking sntp</h3>
114<span id="index-sntp"></span>
115<span id="index-standard-Simple-Network-Time-Protocol-client-program"></span>
116
117
118
119<p><code>sntp</code>
120can be used as an SNTP client to query a NTP or SNTP server and either display
121the time or set the local system&rsquo;s time (given suitable privilege).  It can be
122run as an interactive command or from a
123<code>cron</code>
124job.
125</p>
126<p>NTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol)
127are defined and described by RFC 5905.
128</p>
129
130<p>The default is to write the estimated correct local date and time (i.e. not
131UTC) to the standard output in a format like:
132</p>
133<p><code>'1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN'</code>
134</p>
135<p>where the
136<code>'(+0800)'</code>
137means that to get to UTC from the reported local time one must
138add 8 hours and 0 minutes,
139the
140<code>'+4.567'</code>
141indicates the local clock is 4.567 seconds behind the correct time
142(so 4.567 seconds must be added to the local clock to get it to be correct).
143Note that the number of decimals printed for this value will change
144based on the reported precision of the server.
145<code>'+/- 0.089'</code>
146is the reported
147<em>synchronization</em> <em>distance</em>
148(in seconds), which represents the maximum error due to all causes.
149If the server does not report valid data needed to calculate the
150synchronization distance, this will be reported as
151<code>'+/- ?'</code>.
152If the
153<em>host</em>
154is different from the
155<em>IP</em>,
156both will be displayed.
157Otherwise, only the
158<em>IP</em>
159is displayed.
160Finally, the
161<em>stratum</em>
162of the host is reported
163and the leap indicator is decoded and displayed.
164</p>
165<p>This section was generated by <strong>AutoGen</strong>,
166using the <code>agtexi-cmd</code> template and the option descriptions for the <code>sntp</code> program.
167This software is released under the NTP license, &lt;http://ntp.org/license&gt;.
168</p>
169<table class="menu" border="0" cellspacing="0">
170<tr><td align="left" valign="top">&bull; <a href="#sntp-usage" accesskey="1">sntp usage</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">sntp help/usage (<samp>--help</samp>)
171</td></tr>
172<tr><td align="left" valign="top">&bull; <a href="#sntp-ipv4" accesskey="2">sntp ipv4</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">ipv4 option (-4)
173</td></tr>
174<tr><td align="left" valign="top">&bull; <a href="#sntp-ipv6" accesskey="3">sntp ipv6</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">ipv6 option (-6)
175</td></tr>
176<tr><td align="left" valign="top">&bull; <a href="#sntp-authentication" accesskey="4">sntp authentication</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">authentication option (-a)
177</td></tr>
178<tr><td align="left" valign="top">&bull; <a href="#sntp-broadcast" accesskey="5">sntp broadcast</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">broadcast option (-b)
179</td></tr>
180<tr><td align="left" valign="top">&bull; <a href="#sntp-concurrent" accesskey="6">sntp concurrent</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">concurrent option (-c)
181</td></tr>
182<tr><td align="left" valign="top">&bull; <a href="#sntp-gap" accesskey="7">sntp gap</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">gap option (-g)
183</td></tr>
184<tr><td align="left" valign="top">&bull; <a href="#sntp-kod" accesskey="8">sntp kod</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">kod option (-K)
185</td></tr>
186<tr><td align="left" valign="top">&bull; <a href="#sntp-keyfile" accesskey="9">sntp keyfile</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">keyfile option (-k)
187</td></tr>
188<tr><td align="left" valign="top">&bull; <a href="#sntp-logfile">sntp logfile</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">logfile option (-l)
189</td></tr>
190<tr><td align="left" valign="top">&bull; <a href="#sntp-steplimit">sntp steplimit</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">steplimit option (-M)
191</td></tr>
192<tr><td align="left" valign="top">&bull; <a href="#sntp-ntpversion">sntp ntpversion</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">ntpversion option (-o)
193</td></tr>
194<tr><td align="left" valign="top">&bull; <a href="#sntp-usereservedport">sntp usereservedport</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">usereservedport option (-r)
195</td></tr>
196<tr><td align="left" valign="top">&bull; <a href="#sntp-timeout">sntp timeout</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">timeout option (-t)
197</td></tr>
198<tr><td align="left" valign="top">&bull; <a href="#sntp-wait">sntp wait</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">wait option
199</td></tr>
200<tr><td align="left" valign="top">&bull; <a href="#sntp-config">sntp config</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">presetting/configuring sntp
201</td></tr>
202<tr><td align="left" valign="top">&bull; <a href="#sntp-exit-status">sntp exit status</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">exit status
203</td></tr>
204<tr><td align="left" valign="top">&bull; <a href="#sntp-Usage">sntp Usage</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Usage
205</td></tr>
206<tr><td align="left" valign="top">&bull; <a href="#sntp-Authors">sntp Authors</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Authors
207</td></tr>
208</table>
209
210<hr>
211<span id="sntp-usage"></span><div class="header">
212<p>
213Next: <a href="#sntp-ipv4" accesskey="n" rel="next">sntp ipv4</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
214</div>
215<span id="sntp-help_002fusage-_0028_002d_002dhelp_0029"></span><h4 class="subsection">1.1.1 sntp help/usage (<samp>--help</samp>)</h4>
216<span id="index-sntp-help"></span>
217
218<p>This is the automatically generated usage text for sntp.
219</p>
220<p>The text printed is the same whether selected with the <code>help</code> option
221(<samp>--help</samp>) or the <code>more-help</code> option (<samp>--more-help</samp>).  <code>more-help</code> will print
222the usage text by passing it through a pager program.
223<code>more-help</code> is disabled on platforms without a working
224<code>fork(2)</code> function.  The <code>PAGER</code> environment variable is
225used to select the program, defaulting to <samp>more</samp>.  Both will exit
226with a status code of 0.
227</p>
228<div class="example">
229<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p17
230Usage:  sntp [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
231                [ hostname-or-IP ...]
232  Flg Arg Option-Name    Description
233   -4 no  ipv4           Force IPv4 DNS name resolution
234                                - prohibits the option 'ipv6'
235   -6 no  ipv6           Force IPv6 DNS name resolution
236                                - prohibits the option 'ipv4'
237   -a Num authentication Enable authentication with the key auth-keynumber
238   -b Str broadcast      Listen to the address specified for broadcast time sync
239                                - may appear multiple times
240   -c Str concurrent     Concurrently query all IPs returned for host-name
241                                - may appear multiple times
242   -d no  debug-level    Increase debug verbosity level
243                                - may appear multiple times
244   -D Num set-debug-level Set the debug verbosity level
245                                - may appear multiple times
246   -g Num gap            The gap (in milliseconds) between time requests
247   -K Fil kod            KoD history filename
248   -k Fil keyfile        Look in this file for the key specified with -a
249   -l Fil logfile        Log to specified logfile
250   -M Num steplimit      Adjustments less than steplimit msec will be slewed
251                                - it must be in the range:
252                                  greater than or equal to 0
253   -o Num ntpversion     Send int as our NTP protocol version
254                                - it must be in the range:
255                                  0 to 7
256   -r no  usereservedport Use the NTP Reserved Port (port 123)
257   -S no  step           OK to 'step' the time with settimeofday(2)
258   -s no  slew           OK to 'slew' the time with adjtime(2)
259   -t Num timeout        The number of seconds to wait for responses
260      no  wait           Wait for pending replies (if not setting the time)
261                                - disabled as '--no-wait'
262                                - enabled by default
263      opt version        output version information and exit
264   -? no  help           display extended usage information and exit
265   -! no  more-help      extended usage information passed thru pager
266   -&gt; opt save-opts      save the option state to a config file
267   -&lt; Str load-opts      load options from a config file
268                                - disabled as '--no-load-opts'
269                                - may appear multiple times
270
271Options are specified by doubled hyphens and their name or by a single
272hyphen and the flag character.
273
274
275The following option preset mechanisms are supported:
276 - reading file $HOME/.ntprc
277 - reading file ./.ntprc
278 - examining environment variables named SNTP_*
279
280Please send bug reports to:  &lt;https://bugs.ntp.org, bugs@ntp.org&gt;
281</pre></div>
282
283<hr>
284<span id="sntp-ipv4"></span><div class="header">
285<p>
286Next: <a href="#sntp-ipv6" accesskey="n" rel="next">sntp ipv6</a>, Previous: <a href="#sntp-usage" accesskey="p" rel="prev">sntp usage</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
287</div>
288<span id="ipv4-option-_0028_002d4_0029"></span><h4 class="subsection">1.1.2 ipv4 option (-4)</h4>
289<span id="index-sntp_002dipv4"></span>
290
291<p>This is the &ldquo;force ipv4 dns name resolution&rdquo; option.
292</p>
293<p>This option has some usage constraints.  It:
294</p><ul>
295<li> must not appear in combination with any of the following options:
296ipv6.
297</li></ul>
298
299<p>Force DNS resolution of the following host names on the command line
300to the IPv4 namespace.
301</p><hr>
302<span id="sntp-ipv6"></span><div class="header">
303<p>
304Next: <a href="#sntp-authentication" accesskey="n" rel="next">sntp authentication</a>, Previous: <a href="#sntp-ipv4" accesskey="p" rel="prev">sntp ipv4</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
305</div>
306<span id="ipv6-option-_0028_002d6_0029"></span><h4 class="subsection">1.1.3 ipv6 option (-6)</h4>
307<span id="index-sntp_002dipv6"></span>
308
309<p>This is the &ldquo;force ipv6 dns name resolution&rdquo; option.
310</p>
311<p>This option has some usage constraints.  It:
312</p><ul>
313<li> must not appear in combination with any of the following options:
314ipv4.
315</li></ul>
316
317<p>Force DNS resolution of the following host names on the command line
318to the IPv6 namespace.
319</p><hr>
320<span id="sntp-authentication"></span><div class="header">
321<p>
322Next: <a href="#sntp-broadcast" accesskey="n" rel="next">sntp broadcast</a>, Previous: <a href="#sntp-ipv6" accesskey="p" rel="prev">sntp ipv6</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
323</div>
324<span id="authentication-option-_0028_002da_0029"></span><h4 class="subsection">1.1.4 authentication option (-a)</h4>
325<span id="index-sntp_002dauthentication"></span>
326
327<p>This is the &ldquo;enable authentication with the key <var>auth-keynumber</var>&rdquo; option.
328This option takes a number argument <samp>auth-keynumber</samp>.
329Enable authentication using the key specified in this option&rsquo;s
330argument.  The argument of this option is the <samp>keyid</samp>, a
331number specified in the <samp>keyfile</samp> as this key&rsquo;s identifier.
332See the <samp>keyfile</samp> option (<samp>-k</samp>) for more details.
333</p><hr>
334<span id="sntp-broadcast"></span><div class="header">
335<p>
336Next: <a href="#sntp-concurrent" accesskey="n" rel="next">sntp concurrent</a>, Previous: <a href="#sntp-authentication" accesskey="p" rel="prev">sntp authentication</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
337</div>
338<span id="broadcast-option-_0028_002db_0029"></span><h4 class="subsection">1.1.5 broadcast option (-b)</h4>
339<span id="index-sntp_002dbroadcast"></span>
340
341<p>This is the &ldquo;listen to the address specified for broadcast time sync&rdquo; option.
342This option takes a string argument <samp>broadcast-address</samp>.
343</p>
344<p>This option has some usage constraints.  It:
345</p><ul>
346<li> may appear an unlimited number of times.
347</li></ul>
348
349<p>If specified <code>sntp</code> will listen to the specified address
350for NTP broadcasts.  The default maximum wait time
351can (and probably should) be modified with <samp>-t</samp>.
352</p><hr>
353<span id="sntp-concurrent"></span><div class="header">
354<p>
355Next: <a href="#sntp-gap" accesskey="n" rel="next">sntp gap</a>, Previous: <a href="#sntp-broadcast" accesskey="p" rel="prev">sntp broadcast</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
356</div>
357<span id="concurrent-option-_0028_002dc_0029"></span><h4 class="subsection">1.1.6 concurrent option (-c)</h4>
358<span id="index-sntp_002dconcurrent"></span>
359
360<p>This is the &ldquo;concurrently query all ips returned for host-name&rdquo; option.
361This option takes a string argument <samp>host-name</samp>.
362</p>
363<p>This option has some usage constraints.  It:
364</p><ul>
365<li> may appear an unlimited number of times.
366</li></ul>
367
368<p>Requests from an NTP &quot;client&quot; to a &quot;server&quot; should never be sent
369more rapidly than one every 2 seconds.  By default, any IPs returned
370as part of a DNS lookup are assumed to be for a single instance of
371<code>ntpd</code>, and therefore <code>sntp</code> will send queries to these IPs
372one after another, with a 2-second gap in between each query.
373</p>
374<p>The <samp>-c</samp> or <samp>--concurrent</samp> flag says that any IPs
375returned for the DNS lookup of the supplied host-name are on
376different machines, so we can send concurrent queries.
377</p><hr>
378<span id="sntp-gap"></span><div class="header">
379<p>
380Next: <a href="#sntp-kod" accesskey="n" rel="next">sntp kod</a>, Previous: <a href="#sntp-concurrent" accesskey="p" rel="prev">sntp concurrent</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
381</div>
382<span id="gap-option-_0028_002dg_0029"></span><h4 class="subsection">1.1.7 gap option (-g)</h4>
383<span id="index-sntp_002dgap"></span>
384
385<p>This is the &ldquo;the gap (in milliseconds) between time requests&rdquo; option.
386This option takes a number argument <samp>milliseconds</samp>.
387Since we&rsquo;re only going to use the first valid response we get and
388there is benefit to specifying a good number of servers to query,
389separate the queries we send out by the specified number of
390milliseconds.
391</p><hr>
392<span id="sntp-kod"></span><div class="header">
393<p>
394Next: <a href="#sntp-keyfile" accesskey="n" rel="next">sntp keyfile</a>, Previous: <a href="#sntp-gap" accesskey="p" rel="prev">sntp gap</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
395</div>
396<span id="kod-option-_0028_002dK_0029"></span><h4 class="subsection">1.1.8 kod option (-K)</h4>
397<span id="index-sntp_002dkod"></span>
398
399<p>This is the &ldquo;kod history filename&rdquo; option.
400This option takes a file argument <samp>file-name</samp>.
401Specifies the filename to be used for the persistent history of KoD
402responses received from servers.  If the file does not exist, a
403warning message will be displayed.  The file will not be created.
404</p><hr>
405<span id="sntp-keyfile"></span><div class="header">
406<p>
407Next: <a href="#sntp-logfile" accesskey="n" rel="next">sntp logfile</a>, Previous: <a href="#sntp-kod" accesskey="p" rel="prev">sntp kod</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
408</div>
409<span id="keyfile-option-_0028_002dk_0029"></span><h4 class="subsection">1.1.9 keyfile option (-k)</h4>
410<span id="index-sntp_002dkeyfile"></span>
411
412<p>This is the &ldquo;look in this file for the key specified with <samp>-a</samp>&rdquo; option.
413This option takes a file argument <samp>file-name</samp>.
414This option specifies the keyfile.
415<code>sntp</code> will search for the key specified with <samp>-a</samp>
416<samp>keyno</samp> in this file.  See <code>ntp.keys(5)</code> for more
417information.
418</p><hr>
419<span id="sntp-logfile"></span><div class="header">
420<p>
421Next: <a href="#sntp-steplimit" accesskey="n" rel="next">sntp steplimit</a>, Previous: <a href="#sntp-keyfile" accesskey="p" rel="prev">sntp keyfile</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
422</div>
423<span id="logfile-option-_0028_002dl_0029"></span><h4 class="subsection">1.1.10 logfile option (-l)</h4>
424<span id="index-sntp_002dlogfile"></span>
425
426<p>This is the &ldquo;log to specified logfile&rdquo; option.
427This option takes a file argument <samp>file-name</samp>.
428This option causes the client to write log messages to the specified
429<samp>logfile</samp>.
430</p><hr>
431<span id="sntp-steplimit"></span><div class="header">
432<p>
433Next: <a href="#sntp-ntpversion" accesskey="n" rel="next">sntp ntpversion</a>, Previous: <a href="#sntp-logfile" accesskey="p" rel="prev">sntp logfile</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
434</div>
435<span id="steplimit-option-_0028_002dM_0029"></span><h4 class="subsection">1.1.11 steplimit option (-M)</h4>
436<span id="index-sntp_002dsteplimit"></span>
437
438<p>This is the &ldquo;adjustments less than <var>steplimit</var> msec will be slewed&rdquo; option.
439This option takes a number argument.
440If the time adjustment is less than <samp>steplimit</samp> milliseconds,
441slew the amount using <code>adjtime(2)</code>.  Otherwise, step the
442correction using <code>settimeofday(2)</code>.  The default value is 0,
443which means all adjustments will be stepped.  This is a feature, as
444different situations demand different values.
445</p><hr>
446<span id="sntp-ntpversion"></span><div class="header">
447<p>
448Next: <a href="#sntp-usereservedport" accesskey="n" rel="next">sntp usereservedport</a>, Previous: <a href="#sntp-steplimit" accesskey="p" rel="prev">sntp steplimit</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
449</div>
450<span id="ntpversion-option-_0028_002do_0029"></span><h4 class="subsection">1.1.12 ntpversion option (-o)</h4>
451<span id="index-sntp_002dntpversion"></span>
452
453<p>This is the &ldquo;send <var>int</var> as our ntp protocol version&rdquo; option.
454This option takes a number argument.
455When sending requests to a remote server, tell them we are running
456NTP protocol version <samp>ntpversion</samp> .
457</p><hr>
458<span id="sntp-usereservedport"></span><div class="header">
459<p>
460Next: <a href="#sntp-timeout" accesskey="n" rel="next">sntp timeout</a>, Previous: <a href="#sntp-ntpversion" accesskey="p" rel="prev">sntp ntpversion</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
461</div>
462<span id="usereservedport-option-_0028_002dr_0029"></span><h4 class="subsection">1.1.13 usereservedport option (-r)</h4>
463<span id="index-sntp_002dusereservedport"></span>
464
465<p>This is the &ldquo;use the ntp reserved port (port 123)&rdquo; option.
466Use port 123, which is reserved for NTP, for our network
467communications.
468</p><hr>
469<span id="sntp-timeout"></span><div class="header">
470<p>
471Next: <a href="#sntp-wait" accesskey="n" rel="next">sntp wait</a>, Previous: <a href="#sntp-usereservedport" accesskey="p" rel="prev">sntp usereservedport</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
472</div>
473<span id="timeout-option-_0028_002dt_0029"></span><h4 class="subsection">1.1.14 timeout option (-t)</h4>
474<span id="index-sntp_002dtimeout"></span>
475
476<p>This is the &ldquo;the number of seconds to wait for responses&rdquo; option.
477This option takes a number argument <samp>seconds</samp>.
478When waiting for a reply, <code>sntp</code> will wait the number
479of seconds specified before giving up.  The default should be
480more than enough for a unicast response.  If <code>sntp</code> is
481only waiting for a broadcast response a longer timeout is
482likely needed.
483</p><hr>
484<span id="sntp-wait"></span><div class="header">
485<p>
486Next: <a href="#sntp-config" accesskey="n" rel="next">sntp config</a>, Previous: <a href="#sntp-timeout" accesskey="p" rel="prev">sntp timeout</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
487</div>
488<span id="wait-option"></span><h4 class="subsection">1.1.15 wait option</h4>
489<span id="index-sntp_002dwait"></span>
490
491<p>This is the &ldquo;wait for pending replies (if not setting the time)&rdquo; option.
492</p>
493<p>This option has some usage constraints.  It:
494</p><ul>
495<li> can be disabled with &ndash;no-wait.
496</li><li> It is enabled by default.
497</li></ul>
498
499<p>If we are not setting the time, wait for all pending responses.
500</p>
501
502<hr>
503<span id="sntp-config"></span><div class="header">
504<p>
505Next: <a href="#sntp-exit-status" accesskey="n" rel="next">sntp exit status</a>, Previous: <a href="#sntp-wait" accesskey="p" rel="prev">sntp wait</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
506</div>
507<span id="presetting_002fconfiguring-sntp"></span><h4 class="subsection">1.1.16 presetting/configuring sntp</h4>
508
509<p>Any option that is not marked as <i>not presettable</i> may be preset by
510loading values from configuration (&quot;rc&quot; or &quot;ini&quot;) files, and values from environment variables named <code>SNTP</code> and <code>SNTP_&lt;OPTION_NAME&gt;</code>.  <code>&lt;OPTION_NAME&gt;</code> must be one of
511the options listed above in upper case and segmented with underscores.
512The <code>SNTP</code> variable will be tokenized and parsed like
513the command line.  The remaining variables are tested for existence and their
514values are treated like option arguments.
515</p>
516
517<p><code>libopts</code> will search in 2 places for configuration files:
518</p><ul>
519<li> $HOME
520</li><li> $PWD
521</li></ul>
522<p>The environment variables <code>HOME</code>, and <code>PWD</code>
523are expanded and replaced when <samp>sntp</samp> runs.
524For any of these that are plain files, they are simply processed.
525For any that are directories, then a file named <samp>.ntprc</samp> is searched for
526within that directory and processed.
527</p>
528<p>Configuration files may be in a wide variety of formats.
529The basic format is an option name followed by a value (argument) on the
530same line.  Values may be separated from the option name with a colon,
531equal sign or simply white space.  Values may be continued across multiple
532lines by escaping the newline with a backslash.
533</p>
534<p>Multiple programs may also share the same initialization file.
535Common options are collected at the top, followed by program specific
536segments.  The segments are separated by lines like:
537</p><div class="example">
538<pre class="example">[SNTP]
539</pre></div>
540<p>or by
541</p><div class="example">
542<pre class="example">&lt;?program sntp&gt;
543</pre></div>
544<p>Do not mix these styles within one configuration file.
545</p>
546<p>Compound values and carefully constructed string values may also be
547specified using XML syntax:
548</p><div class="example">
549<pre class="example">&lt;option-name&gt;
550   &lt;sub-opt&gt;...&amp;lt;...&amp;gt;...&lt;/sub-opt&gt;
551&lt;/option-name&gt;
552</pre></div>
553<p>yielding an <code>option-name.sub-opt</code> string value of
554</p><div class="example">
555<pre class="example">&quot;...&lt;...&gt;...&quot;
556</pre></div>
557<p><code>AutoOpts</code> does not track suboptions.  You simply note that it is a
558hierarchicly valued option.  <code>AutoOpts</code> does provide a means for searching
559the associated name/value pair list (see: optionFindValue).
560</p>
561<p>The command line options relating to configuration and/or usage help are:
562</p>
563<span id="version-_0028_002d_0029"></span><h4 class="subsubheading">version (-)</h4>
564
565<p>Print the program version to standard out, optionally with licensing
566information, then exit 0.  The optional argument specifies how much licensing
567detail to provide.  The default is to print just the version.  The licensing information may be selected with an option argument.
568Only the first letter of the argument is examined:
569</p>
570<dl compact="compact">
571<dt>&lsquo;<samp>version</samp>&rsquo;</dt>
572<dd><p>Only print the version.  This is the default.
573</p></dd>
574<dt>&lsquo;<samp>copyright</samp>&rsquo;</dt>
575<dd><p>Name the copyright usage licensing terms.
576</p></dd>
577<dt>&lsquo;<samp>verbose</samp>&rsquo;</dt>
578<dd><p>Print the full copyright usage licensing terms.
579</p></dd>
580</dl>
581
582<hr>
583<span id="sntp-exit-status"></span><div class="header">
584<p>
585Next: <a href="#sntp-Usage" accesskey="n" rel="next">sntp Usage</a>, Previous: <a href="#sntp-config" accesskey="p" rel="prev">sntp config</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
586</div>
587<span id="sntp-exit-status-1"></span><h4 class="subsection">1.1.17 sntp exit status</h4>
588
589<p>One of the following exit values will be returned:
590</p><dl compact="compact">
591<dt>&lsquo;<samp>0 (EXIT_SUCCESS)</samp>&rsquo;</dt>
592<dd><p>Successful program execution.
593</p></dd>
594<dt>&lsquo;<samp>1 (EXIT_FAILURE)</samp>&rsquo;</dt>
595<dd><p>The operation failed or the command syntax was not valid.
596</p></dd>
597<dt>&lsquo;<samp>66 (EX_NOINPUT)</samp>&rsquo;</dt>
598<dd><p>A specified configuration file could not be loaded.
599</p></dd>
600<dt>&lsquo;<samp>70 (EX_SOFTWARE)</samp>&rsquo;</dt>
601<dd><p>libopts had an internal operational error.  Please report
602it to autogen-users@lists.sourceforge.net.  Thank you.
603</p></dd>
604</dl>
605<hr>
606<span id="sntp-Usage"></span><div class="header">
607<p>
608Next: <a href="#sntp-Authors" accesskey="n" rel="next">sntp Authors</a>, Previous: <a href="#sntp-exit-status" accesskey="p" rel="prev">sntp exit status</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
609</div>
610<span id="sntp-Usage-1"></span><h4 class="subsection">1.1.18 sntp Usage</h4>
611<hr>
612<span id="sntp-Authors"></span><div class="header">
613<p>
614Previous: <a href="#sntp-Usage" accesskey="p" rel="prev">sntp Usage</a>, Up: <a href="#sntp-Invocation" accesskey="u" rel="up">sntp Invocation</a> &nbsp; </p>
615</div>
616<span id="sntp-Authors-1"></span><h4 class="subsection">1.1.19 sntp Authors</h4>
617
618<hr>
619<span id="Usage"></span><div class="header">
620<p>
621Previous: <a href="#sntp-Invocation" accesskey="p" rel="prev">sntp Invocation</a>, Up: <a href="#sntp-Description" accesskey="u" rel="up">sntp Description</a> &nbsp; </p>
622</div>
623<span id="Usage-1"></span><h3 class="section">1.2 Usage</h3>
624
625<p>The simplest use of this program is as an unprivileged command to
626check the current time, offset, and error in the local clock.
627For example:
628</p>
629<div class="example">
630<pre class="example">sntp ntpserver.somewhere
631</pre></div>
632
633<p>With suitable privilege, it can be run as a command or in a
634<code>crom</code> job to reset the local clock from a reliable server, like
635the <code>ntpdate</code> and <code>rdate</code> commands.
636For example:
637</p>
638<div class="example">
639<pre class="example">sntp -a ntpserver.somewhere
640</pre></div>
641<hr>
642
643
644
645</body>
646</html>
647