xref: /freebsd/contrib/ntp/sntp/sntp.1sntpmdoc (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
1*f5f40dd6SCy Schubert.Dd May 25 2024
22b15cb3dSCy Schubert.Dt SNTP 1sntpmdoc User Commands
32b15cb3dSCy Schubert.Os
42b15cb3dSCy Schubert.\"  EDIT THIS FILE WITH CAUTION  (sntp-opts.mdoc)
52b15cb3dSCy Schubert.\"
6*f5f40dd6SCy Schubert.\"  It has been AutoGen-ed  May 25, 2024 at 12:02:26 AM by AutoGen 5.18.16
72b15cb3dSCy Schubert.\"  From the definitions    sntp-opts.def
82b15cb3dSCy Schubert.\"  and the template file   agmdoc-cmd.tpl
92b15cb3dSCy Schubert.Sh NAME
102b15cb3dSCy Schubert.Nm sntp
112b15cb3dSCy Schubert.Nd standard Simple Network Time Protocol client program
122b15cb3dSCy Schubert.Sh SYNOPSIS
132b15cb3dSCy Schubert.Nm
142b15cb3dSCy Schubert.\" Mixture of short (flag) options and long options
152b15cb3dSCy Schubert.Op Fl flags
162b15cb3dSCy Schubert.Op Fl flag Op Ar value
172b15cb3dSCy Schubert.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc
182b15cb3dSCy Schubert[ hostname\-or\-IP ...]
192b15cb3dSCy Schubert.Pp
202b15cb3dSCy Schubert.Sh DESCRIPTION
212b15cb3dSCy Schubert.Nm
222b15cb3dSCy Schubertcan be used as an SNTP client to query a NTP or SNTP server and either display
232b15cb3dSCy Schubertthe time or set the local system's time (given suitable privilege).  It can be
242b15cb3dSCy Schubertrun as an interactive command or from a
252b15cb3dSCy Schubert.Ic cron
262b15cb3dSCy Schubertjob.
272b15cb3dSCy SchubertNTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol)
282b15cb3dSCy Schubertare defined and described by RFC 5905.
292b15cb3dSCy Schubert.Pp
302b15cb3dSCy SchubertThe default is to write the estimated correct local date and time (i.e. not
312b15cb3dSCy SchubertUTC) to the standard output in a format like:
322b15cb3dSCy Schubert.Ic "'1996\-10\-15 20:17:25.123 (+0800) +4.567 +/\- 0.089 [host] IP sN'"
332b15cb3dSCy Schubertwhere the
342b15cb3dSCy Schubert.Ic "'(+0800)'"
352b15cb3dSCy Schubertmeans that to get to UTC from the reported local time one must
362b15cb3dSCy Schubertadd 8 hours and 0 minutes,
372b15cb3dSCy Schubertthe
382b15cb3dSCy Schubert.Ic "'+4.567'"
392b15cb3dSCy Schubertindicates the local clock is 4.567 seconds behind the correct time
402b15cb3dSCy Schubert(so 4.567 seconds must be added to the local clock to get it to be correct).
412b15cb3dSCy SchubertNote that the number of decimals printed for this value will change
422b15cb3dSCy Schubertbased on the reported precision of the server.
432b15cb3dSCy Schubert.Ic "'+/\- 0.089'"
442b15cb3dSCy Schubertis the reported
452b15cb3dSCy Schubert.Em synchronization distance
462b15cb3dSCy Schubert(in seconds), which represents the maximum error due to all causes.
472b15cb3dSCy SchubertIf the server does not report valid data needed to calculate the
482b15cb3dSCy Schubertsynchronization distance, this will be reported as
492b15cb3dSCy Schubert.Ic "'+/\- ?'" .
502b15cb3dSCy SchubertIf the
512b15cb3dSCy Schubert.Em host
522b15cb3dSCy Schubertis different from the
532b15cb3dSCy Schubert.Em IP ,
542b15cb3dSCy Schubertboth will be displayed.
552b15cb3dSCy SchubertOtherwise, only the
562b15cb3dSCy Schubert.Em IP
572b15cb3dSCy Schubertis displayed.
582b15cb3dSCy SchubertFinally, the
592b15cb3dSCy Schubert.Em stratum
60a25439b6SCy Schubertof the host is reported
61a25439b6SCy Schubertand the leap indicator is decoded and displayed.
622b15cb3dSCy Schubert.Sh "OPTIONS"
632b15cb3dSCy Schubert.Bl -tag
642b15cb3dSCy Schubert.It  Fl 4 , Fl \-ipv4
652b15cb3dSCy SchubertForce IPv4 DNS name resolution.
662b15cb3dSCy SchubertThis option must not appear in combination with any of the following options:
672b15cb3dSCy Schubertipv6.
682b15cb3dSCy Schubert.sp
692b15cb3dSCy SchubertForce DNS resolution of the following host names on the command line
702b15cb3dSCy Schubertto the IPv4 namespace.
712b15cb3dSCy Schubert.It  Fl 6 , Fl \-ipv6
722b15cb3dSCy SchubertForce IPv6 DNS name resolution.
732b15cb3dSCy SchubertThis option must not appear in combination with any of the following options:
742b15cb3dSCy Schubertipv4.
752b15cb3dSCy Schubert.sp
762b15cb3dSCy SchubertForce DNS resolution of the following host names on the command line
772b15cb3dSCy Schubertto the IPv6 namespace.
782b15cb3dSCy Schubert.It  Fl a Ar auth\-keynumber , Fl \-authentication Ns = Ns Ar auth\-keynumber
792b15cb3dSCy SchubertEnable authentication with the key \fBauth\-keynumber\fP.
802b15cb3dSCy SchubertThis option takes an integer number as its argument.
812b15cb3dSCy Schubert.sp
822b15cb3dSCy SchubertEnable authentication using the key specified in this option's
832b15cb3dSCy Schubertargument.  The argument of this option is the \fBkeyid\fP, a
842b15cb3dSCy Schubertnumber specified in the \fBkeyfile\fP as this key's identifier.
852b15cb3dSCy SchubertSee the \fBkeyfile\fP option (\fB\-k\fP) for more details.
862b15cb3dSCy Schubert.It  Fl b Ar broadcast\-address , Fl \-broadcast Ns = Ns Ar broadcast\-address
872b15cb3dSCy SchubertListen to the address specified for broadcast time sync.
882b15cb3dSCy SchubertThis option may appear an unlimited number of times.
892b15cb3dSCy Schubert.sp
902b15cb3dSCy SchubertIf specified \fBsntp\fP will listen to the specified address
912b15cb3dSCy Schubertfor NTP broadcasts.  The default maximum wait time
922b15cb3dSCy Schubertcan (and probably should) be modified with \fB\-t\fP.
932b15cb3dSCy Schubert.It  Fl c Ar host\-name , Fl \-concurrent Ns = Ns Ar host\-name
942b15cb3dSCy SchubertConcurrently query all IPs returned for host\-name.
952b15cb3dSCy SchubertThis option may appear an unlimited number of times.
962b15cb3dSCy Schubert.sp
972b15cb3dSCy SchubertRequests from an NTP "client" to a "server" should never be sent
982b15cb3dSCy Schubertmore rapidly than one every 2 seconds.  By default, any IPs returned
992b15cb3dSCy Schubertas part of a DNS lookup are assumed to be for a single instance of
1002b15cb3dSCy Schubert\fBntpd\fP, and therefore \fBsntp\fP will send queries to these IPs
1012b15cb3dSCy Schubertone after another, with a 2\-second gap in between each query.
1022b15cb3dSCy Schubert.sp
1032b15cb3dSCy SchubertThe \fB\-c\fP or \fB\-\-concurrent\fP flag says that any IPs
1042b15cb3dSCy Schubertreturned for the DNS lookup of the supplied host\-name are on
1052b15cb3dSCy Schubertdifferent machines, so we can send concurrent queries.
1062b15cb3dSCy Schubert.It  Fl d , Fl \-debug\-level
1072b15cb3dSCy SchubertIncrease debug verbosity level.
1082b15cb3dSCy SchubertThis option may appear an unlimited number of times.
1092b15cb3dSCy Schubert.sp
1102b15cb3dSCy Schubert.It  Fl D Ar number , Fl \-set\-debug\-level Ns = Ns Ar number
1112b15cb3dSCy SchubertSet the debug verbosity level.
1122b15cb3dSCy SchubertThis option may appear an unlimited number of times.
1132b15cb3dSCy SchubertThis option takes an integer number as its argument.
1142b15cb3dSCy Schubert.sp
1152b15cb3dSCy Schubert.It  Fl g Ar milliseconds , Fl \-gap Ns = Ns Ar milliseconds
1162b15cb3dSCy SchubertThe gap (in milliseconds) between time requests.
1172b15cb3dSCy SchubertThis option takes an integer number as its argument.
1182b15cb3dSCy SchubertThe default
1192b15cb3dSCy Schubert.Ar milliseconds
1202b15cb3dSCy Schubertfor this option is:
1212b15cb3dSCy Schubert.ti +4
1222b15cb3dSCy Schubert 50
1232b15cb3dSCy Schubert.sp
1242b15cb3dSCy SchubertSince we're only going to use the first valid response we get and
1252b15cb3dSCy Schubertthere is benefit to specifying a good number of servers to query,
1262b15cb3dSCy Schubertseparate the queries we send out by the specified number of
1272b15cb3dSCy Schubertmilliseconds.
1282b15cb3dSCy Schubert.It  Fl K Ar file\-name , Fl \-kod Ns = Ns Ar file\-name
1292b15cb3dSCy SchubertKoD history filename.
1302b15cb3dSCy SchubertThe default
1312b15cb3dSCy Schubert.Ar file\-name
1322b15cb3dSCy Schubertfor this option is:
1332b15cb3dSCy Schubert.ti +4
1342b15cb3dSCy Schubert /var/db/ntp\-kod
1352b15cb3dSCy Schubert.sp
1362b15cb3dSCy SchubertSpecifies the filename to be used for the persistent history of KoD
1372b15cb3dSCy Schubertresponses received from servers.  If the file does not exist, a
1382b15cb3dSCy Schubertwarning message will be displayed.  The file will not be created.
1392b15cb3dSCy Schubert.It  Fl k Ar file\-name , Fl \-keyfile Ns = Ns Ar file\-name
1402b15cb3dSCy SchubertLook in this file for the key specified with \fB\-a\fP.
14109100258SXin LIThe default
14209100258SXin LI.Ar file\-name
14309100258SXin LIfor this option is:
14409100258SXin LI.ti +4
14509100258SXin LI /etc/ntp.keys
1462b15cb3dSCy Schubert.sp
1472b15cb3dSCy SchubertThis option specifies the keyfile.
1482b15cb3dSCy Schubert\fBsntp\fP will search for the key specified with \fB\-a\fP
1492b15cb3dSCy Schubert\fIkeyno\fP in this file.  See \fBntp.keys(5)\fP for more
1502b15cb3dSCy Schubertinformation.
1512b15cb3dSCy Schubert.It  Fl l Ar file\-name , Fl \-logfile Ns = Ns Ar file\-name
1522b15cb3dSCy SchubertLog to specified logfile.
1532b15cb3dSCy Schubert.sp
1542b15cb3dSCy SchubertThis option causes the client to write log messages to the specified
1552b15cb3dSCy Schubert\fIlogfile\fP.
1562b15cb3dSCy Schubert.It  Fl M Ar number , Fl \-steplimit Ns = Ns Ar number
1572b15cb3dSCy SchubertAdjustments less than \fBsteplimit\fP msec will be slewed.
1582b15cb3dSCy SchubertThis option takes an integer number as its argument.
1592b15cb3dSCy SchubertThe value of
1602b15cb3dSCy Schubert.Ar number
1612b15cb3dSCy Schubertis constrained to being:
1622b15cb3dSCy Schubert.in +4
1632b15cb3dSCy Schubert.nf
1642b15cb3dSCy Schubert.na
1652b15cb3dSCy Schubertgreater than or equal to 0
1662b15cb3dSCy Schubert.fi
1672b15cb3dSCy Schubert.in -4
1682b15cb3dSCy Schubert.sp
1692b15cb3dSCy SchubertIf the time adjustment is less than \fIsteplimit\fP milliseconds,
1702b15cb3dSCy Schubertslew the amount using \fBadjtime(2)\fP.  Otherwise, step the
1712b15cb3dSCy Schubertcorrection using \fBsettimeofday(2)\fP.  The default value is 0,
1722b15cb3dSCy Schubertwhich means all adjustments will be stepped.  This is a feature, as
1732b15cb3dSCy Schubertdifferent situations demand different values.
1742b15cb3dSCy Schubert.It  Fl o Ar number , Fl \-ntpversion Ns = Ns Ar number
1752b15cb3dSCy SchubertSend \fBint\fP as our NTP protocol version.
1762b15cb3dSCy SchubertThis option takes an integer number as its argument.
1772b15cb3dSCy SchubertThe value of
1782b15cb3dSCy Schubert.Ar number
1792b15cb3dSCy Schubertis constrained to being:
1802b15cb3dSCy Schubert.in +4
1812b15cb3dSCy Schubert.nf
1822b15cb3dSCy Schubert.na
1832b15cb3dSCy Schubertin the range  0 through 7
1842b15cb3dSCy Schubert.fi
1852b15cb3dSCy Schubert.in -4
1862b15cb3dSCy SchubertThe default
1872b15cb3dSCy Schubert.Ar number
1882b15cb3dSCy Schubertfor this option is:
1892b15cb3dSCy Schubert.ti +4
1902b15cb3dSCy Schubert 4
1912b15cb3dSCy Schubert.sp
1922b15cb3dSCy SchubertWhen sending requests to a remote server, tell them we are running
1932b15cb3dSCy SchubertNTP protocol version \fIntpversion\fP .
1942b15cb3dSCy Schubert.It  Fl r , Fl \-usereservedport
1952b15cb3dSCy SchubertUse the NTP Reserved Port (port 123).
1962b15cb3dSCy Schubert.sp
1972b15cb3dSCy SchubertUse port 123, which is reserved for NTP, for our network
1982b15cb3dSCy Schubertcommunications.
1992b15cb3dSCy Schubert.It  Fl S , Fl \-step
2002b15cb3dSCy SchubertOK to 'step' the time with \fBsettimeofday(2)\fP.
2012b15cb3dSCy Schubert.sp
2022b15cb3dSCy Schubert.It  Fl s , Fl \-slew
2032b15cb3dSCy SchubertOK to 'slew' the time with \fBadjtime(2)\fP.
2042b15cb3dSCy Schubert.sp
2052b15cb3dSCy Schubert.It  Fl t Ar seconds , Fl \-timeout Ns = Ns Ar seconds
2062b15cb3dSCy SchubertThe number of seconds to wait for responses.
2072b15cb3dSCy SchubertThis option takes an integer number as its argument.
2082b15cb3dSCy SchubertThe default
2092b15cb3dSCy Schubert.Ar seconds
2102b15cb3dSCy Schubertfor this option is:
2112b15cb3dSCy Schubert.ti +4
2122b15cb3dSCy Schubert 5
2132b15cb3dSCy Schubert.sp
2142b15cb3dSCy SchubertWhen waiting for a reply, \fBsntp\fP will wait the number
2152b15cb3dSCy Schubertof seconds specified before giving up.  The default should be
2162b15cb3dSCy Schubertmore than enough for a unicast response.  If \fBsntp\fP is
2172b15cb3dSCy Schubertonly waiting for a broadcast response a longer timeout is
2182b15cb3dSCy Schubertlikely needed.
2198624bb05SXin LI.It  Fl \-wait , Fl \-no\-wait
2202b15cb3dSCy SchubertWait for pending replies (if not setting the time).
2212b15cb3dSCy SchubertThe \fIno\-wait\fP form will disable the option.
2222b15cb3dSCy SchubertThis option is enabled by default.
2232b15cb3dSCy Schubert.sp
2242b15cb3dSCy SchubertIf we are not setting the time, wait for all pending responses.
2252b15cb3dSCy Schubert.It Fl \&? , Fl \-help
2262b15cb3dSCy SchubertDisplay usage information and exit.
2272b15cb3dSCy Schubert.It Fl \&! , Fl \-more\-help
2282b15cb3dSCy SchubertPass the extended usage information through a pager.
2292b15cb3dSCy Schubert.It Fl > Oo Ar cfgfile Oc , Fl \-save\-opts Oo Ns = Ns Ar cfgfile Oc
2302b15cb3dSCy SchubertSave the option state to \fIcfgfile\fP.  The default is the \fIlast\fP
2312b15cb3dSCy Schubertconfiguration file listed in the \fBOPTION PRESETS\fP section, below.
2322b15cb3dSCy SchubertThe command will exit after updating the config file.
2332b15cb3dSCy Schubert.It Fl < Ar cfgfile , Fl \-load\-opts Ns = Ns Ar cfgfile , Fl \-no\-load\-opts
2342b15cb3dSCy SchubertLoad options from \fIcfgfile\fP.
2352b15cb3dSCy SchubertThe \fIno\-load\-opts\fP form will disable the loading
2362b15cb3dSCy Schubertof earlier config/rc/ini files.  \fI\-\-no\-load\-opts\fP is handled early,
2372b15cb3dSCy Schubertout of order.
2382b15cb3dSCy Schubert.It Fl \-version Op Brq Ar v|c|n
2392b15cb3dSCy SchubertOutput version of program and exit.  The default mode is `v', a simple
2402b15cb3dSCy Schubertversion.  The `c' mode will print copyright information and `n' will
2412b15cb3dSCy Schubertprint the full copyright notice.
2422b15cb3dSCy Schubert.El
2432b15cb3dSCy Schubert.Sh "OPTION PRESETS"
2442b15cb3dSCy SchubertAny option that is not marked as \fInot presettable\fP may be preset
2452b15cb3dSCy Schubertby loading values from configuration ("RC" or ".INI") file(s) and values from
2462b15cb3dSCy Schubertenvironment variables named:
2472b15cb3dSCy Schubert.nf
2482b15cb3dSCy Schubert  \fBSNTP_<option\-name>\fP or \fBSNTP\fP
2492b15cb3dSCy Schubert.fi
2502b15cb3dSCy Schubert.ad
2512b15cb3dSCy SchubertThe environmental presets take precedence (are processed later than)
2522b15cb3dSCy Schubertthe configuration files.
2532b15cb3dSCy SchubertThe \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
2542b15cb3dSCy SchubertIf any of these are directories, then the file \fI.ntprc\fP
2552b15cb3dSCy Schubertis searched for within those directories.
2562b15cb3dSCy Schubert.Sh USAGE
2572b15cb3dSCy Schubert.Bl -tag -width indent
2582b15cb3dSCy Schubert.It Li "sntp ntpserver.somewhere"
2592b15cb3dSCy Schubertis the simplest use of this program
2602b15cb3dSCy Schubertand can be run as an unprivileged command
2612b15cb3dSCy Schubertto check the current time and error in the local clock.
2622b15cb3dSCy Schubert.It Li "sntp \-Ss \-M 128 ntpserver.somewhere"
2632b15cb3dSCy SchubertWith suitable privilege,
2642b15cb3dSCy Schubertrun as a command
2652b15cb3dSCy Schubertor from a
2662b15cb3dSCy Schubert.Xr cron 8
2672b15cb3dSCy Schubertjob,
2682b15cb3dSCy Schubert.Ic "sntp \-Ss \-M 128 ntpserver.somewhere"
2692b15cb3dSCy Schubertwill request the time from the server,
2702b15cb3dSCy Schubertand if that server reports that it is synchronized
2712b15cb3dSCy Schubertthen if the offset adjustment is less than 128 milliseconds
2722b15cb3dSCy Schubertthe correction will be slewed,
2732b15cb3dSCy Schubertand if the correction is more than 128 milliseconds
2742b15cb3dSCy Schubertthe correction  will be stepped.
2752b15cb3dSCy Schubert.It Li "sntp \-S ntpserver.somewhere"
2762b15cb3dSCy SchubertWith suitable privilege,
2772b15cb3dSCy Schubertrun as a command
2782b15cb3dSCy Schubertor from a
2792b15cb3dSCy Schubert.Xr cron 8
2802b15cb3dSCy Schubertjob,
2812b15cb3dSCy Schubert.Ic "sntp \-S ntpserver.somewhere"
2822b15cb3dSCy Schubertwill set (step) the local clock from a synchronized specified server,
2832b15cb3dSCy Schubertlike the (deprecated)
2842b15cb3dSCy Schubert.Xr ntpdate 1ntpdatemdoc ,
2852b15cb3dSCy Schubertor
2862b15cb3dSCy Schubert.Xr rdate 8
2872b15cb3dSCy Schubertcommands.
2882b15cb3dSCy Schubert.El
2892b15cb3dSCy Schubert.Sh "ENVIRONMENT"
2902b15cb3dSCy SchubertSee \fBOPTION PRESETS\fP for configuration environment variables.
2912b15cb3dSCy Schubert.Sh "FILES"
2922b15cb3dSCy SchubertSee \fBOPTION PRESETS\fP for configuration files.
2932b15cb3dSCy Schubert.Sh "EXIT STATUS"
2942b15cb3dSCy SchubertOne of the following exit values will be returned:
2952b15cb3dSCy Schubert.Bl -tag
2962b15cb3dSCy Schubert.It 0 " (EXIT_SUCCESS)"
2972b15cb3dSCy SchubertSuccessful program execution.
2982b15cb3dSCy Schubert.It 1 " (EXIT_FAILURE)"
2992b15cb3dSCy SchubertThe operation failed or the command syntax was not valid.
3002b15cb3dSCy Schubert.It 66 " (EX_NOINPUT)"
3012b15cb3dSCy SchubertA specified configuration file could not be loaded.
3022b15cb3dSCy Schubert.It 70 " (EX_SOFTWARE)"
3032b15cb3dSCy Schubertlibopts had an internal operational error.  Please report
3042b15cb3dSCy Schubertit to autogen\-users@lists.sourceforge.net.  Thank you.
3052b15cb3dSCy Schubert.El
3062b15cb3dSCy Schubert.Sh AUTHORS
3072b15cb3dSCy Schubert.An "Johannes Maximilian Kuehn"
3082b15cb3dSCy Schubert.An "Harlan Stenn"
3092b15cb3dSCy Schubert.An "Dave Hart"
3102b15cb3dSCy Schubert.Sh "COPYRIGHT"
311*f5f40dd6SCy SchubertCopyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
3122b15cb3dSCy SchubertThis program is released under the terms of the NTP license, <http://ntp.org/license>.
3132b15cb3dSCy Schubert.Sh "BUGS"
314a466cc55SCy SchubertPlease send bug reports to: https://bugs.ntp.org, bugs@ntp.org
3152b15cb3dSCy Schubert.Sh "NOTES"
3162b15cb3dSCy SchubertThis manual page was \fIAutoGen\fP\-erated from the \fBsntp\fP
3172b15cb3dSCy Schubertoption definitions.
318