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