SNTP(1) | General Commands Manual (user) | SNTP(1) |
sntp
—
sntp |
[-flags ] [-flag
[value]] [--option-name [[=|
]value]] [ hostname-or-IP ...] |
sntp
can be used as an SNTP client to query a NTP or
SNTP server and either display the time or set the local system's time (given
suitable privilege). It can be run as an interactive command or from a
cron
job. NTP (the Network Time Protocol) and SNTP
(the Simple Network Time Protocol) are defined and described by RFC 5905.
The default is to write the estimated correct local date and time
(i.e. not UTC) to the standard output in a format like:
'1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP
sN'
where the '(+0800)'
means that to get to
UTC from the reported local time one must add 8 hours and 0 minutes, the
'+4.567'
indicates the local clock is 4.567 seconds
behind the correct time (so 4.567 seconds must be added to the local clock
to get it to be correct). Note that the number of decimals printed for this
value will change based on the reported precision of the server.
'+/- 0.089'
is the reported
synchronization distance (in seconds), which represents
the maximum error due to all causes. If the server does not report valid
data needed to calculate the synchronization distance, this will be reported
as '+/- ?'
. If the host is
different from the IP, both will be displayed. Otherwise,
only the IP is displayed. Finally, the
stratum of the host is reported and the leap indicator is
decoded and displayed.
-4
,
--ipv4
Force DNS resolution of the following host names on the command line to the IPv4 namespace.
-6
,
--ipv6
Force DNS resolution of the following host names on the command line to the IPv6 namespace.
-a
auth-keynumber,
--authentication
=auth-keynumberEnable authentication using the key specified in this option's argument. The argument of this option is the keyid, a number specified in the keyfile as this key's identifier. See the keyfile option (-k) for more details.
-b
broadcast-address,
--broadcast
=broadcast-addressIf specified sntp will listen to the specified address for NTP broadcasts. The default maximum wait time can (and probably should) be modified with -t.
-c
host-name,
--concurrent
=host-nameRequests from an NTP "client" to a "server" should never be sent more rapidly than one every 2 seconds. By default, any IPs returned as part of a DNS lookup are assumed to be for a single instance of ntpd, and therefore sntp will send queries to these IPs one after another, with a 2-second gap in between each query.
The -c or --concurrent flag says that any IPs returned for the DNS lookup of the supplied host-name are on different machines, so we can send concurrent queries.
-d
,
--debug-level
-D
number,
--set-debug-level
=number-g
milliseconds,
--gap
=millisecondsSince we're only going to use the first valid response we get and there is benefit to specifying a good number of servers to query, separate the queries we send out by the specified number of milliseconds.
-K
file-name,
--kod
=file-nameSpecifies the filename to be used for the persistent history of KoD responses received from servers. If the file does not exist, a warning message will be displayed. The file will not be created.
-k
file-name,
--keyfile
=file-nameThis option specifies the keyfile. sntp will search for the key specified with -a keyno in this file. See ntp.keys(5) for more information.
-l
file-name,
--logfile
=file-nameThis option causes the client to write log messages to the specified logfile.
-M
number,
--steplimit
=numbergreater than or equal to 0
If the time adjustment is less than steplimit milliseconds, slew the amount using adjtime(2). Otherwise, step the correction using settimeofday(2). The default value is 0, which means all adjustments will be stepped. This is a feature, as different situations demand different values.
-o
number,
--ntpversion
=numberin the range 0 through 7The default number for this option is:
When sending requests to a remote server, tell them we are running NTP protocol version ntpversion .
-r
,
--usereservedport
Use port 123, which is reserved for NTP, for our network communications.
-S
,
--step
-s
,
--slew
-t
seconds,
--timeout
=secondsWhen waiting for a reply, sntp will wait the number of seconds specified before giving up. The default should be more than enough for a unicast response. If sntp is only waiting for a broadcast response a longer timeout is likely needed.
--wait
,
- Fl -no-wait
If we are not setting the time, wait for all pending responses.
-?
,
--help
-!
,
--more-help
->
[cfgfile], --save-opts
[=cfgfile]-<
cfgfile,
--load-opts
=cfgfile,
--no-load-opts
--version
[{v|c|n}]SNTP_<option-name> or SNTPThe environmental presets take precedence (are processed later than) the configuration files. The homerc files are "$HOME", and ".". If any of these are directories, then the file .ntprc is searched for within those directories.
sntp
ntpserver.somewhere
sntp
-Ss -M 128 ntpserver.somewhere
sntp -Ss -M 128 ntpserver.somewhere
will request
the time from the server, and if that server reports that it is
synchronized then if the offset adjustment is less than 128 milliseconds
the correction will be slewed, and if the correction is more than 128
milliseconds the correction will be stepped.sntp
-S ntpserver.somewhere
sntp -S ntpserver.somewhere
will set (step) the
local clock from a synchronized specified server, like the (deprecated)
ntpdate(1ntpdatemdoc),
or rdate(8) commands.August 14 2018 | NetBSD 9.4 |