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