SNTP(8)
π SNTP π
ok so bestie, welcome to the sntp manual β that's section 8 of your System Manager's Manual, and she is the standard Simple Network Time Protocol client program. yes, the whole vibe is "what time is it, actually" and she ate. let's go πβ¨
β¨ NAME β¨
sntp β standard Simple Network Time Protocol client program π«Ά
π¦ SYNOPSIS π¦
sntp [-flags] [-flag [value]] [--option-name[[=| ]value]] [
hostname-or-IP ...]
literally just yeet a hostname or IP at her and she'll figure it out π
πΈ DESCRIPTION πΈ
so sntp can be used as an SNTP client to query an NTP or SNTP server and either display the time or set the local system's time (given suitable privilege). she 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. no cap, that's the whole deal π₯
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'
and let me break down this iconic little string for you, because it's giving main character energy:
(+0800)means that to get to UTC from the reported local time one must add 8 hours and 0 minutes β°+4.567indicates 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. she's adaptive, we love her+/- 0.089is 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+/- ?. π relatable, sometimes we just don't know- 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. yeah she does all that π
π OPTIONS π
okay this is the long part bestie, grab a snack π
-4,--ipv4β force IPv4 DNS name resolution. this option must not appear in combination with any of the following options:ipv6. it forces DNS resolution of the following host names on the command line to the IPv4 namespace. no mixing, she's not about that chaos-6,--ipv6β force IPv6 DNS name resolution. this option must not appear in combination with any of the following options:ipv4. it forces DNS resolution of the following host names on the command line to the IPv6 namespace. also no mixing. pick a lane β¨-aauth-keynumber,--authentication=auth-keynumber β enable authentication with the key auth-keynumber. this option takes an integer number as its argument. enables 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 π-bbroadcast-address,--broadcast=broadcast-address β listen to the address specified for broadcast time sync. this option may appear an unlimited number of times. if specified,sntpwill listen to the specified address for NTP broadcasts. the default maximum wait time can (and probably should) be modified with-tπ‘-chost-name,--concurrent=host-name β concurrently query all IPs returned for host-name. this option may appear an unlimited number of times. so here's the tea: requests 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 ofntpd, and thereforesntpwill send queries to these IPs one after another, with a 2-second gap in between each query. the-cor--concurrentflag says that any IPs returned for the DNS lookup of the supplied host-name are on different machines, so we can send concurrent queries. go off, parallel queen π-d,--debug-levelβ increase debug verbosity level. this option may appear an unlimited number of times. stack 'em, she can take it π-Dnumber,--set-debug-level=number β set the debug verbosity level. this option may appear an unlimited number of times. this option takes an integer number as its argument ποΈ-gmilliseconds,--gap=milliseconds β the gap (in milliseconds) between time requests. this option takes an integer number as its argument. the default milliseconds for this option is:
50
since 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 β±οΈ
-Kfile-name,--kod=file-name β KoD history filename. the default file-name for this option is:
/var/db/ntp-kod
specifies 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. β οΈ important: she reads, she does not write. no creating files behind your back
-kfile-name,--keyfile=file-name β look in this file for the key specified with-a. the default file-name for this option is:
/etc/ntp.keys
this option specifies the keyfile. sntp will search for the key specified with -a keyno in this file. see ntp.keys(5) for more information π
-lfile-name,--logfile=file-name β log to specified logfile. this option causes the client to write log messages to the specified logfile βοΈ-Mnumber,--steplimit=number β adjustments less than steplimit msec will be slewed. this option takes an integer number as its argument. the value of number is constrained to being:
greater 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 π
-onumber,--ntpversion=number β send int as our NTP protocol version. this option takes an integer number as its argument. the value of number is constrained to being:
in the range 0 through 7
the default number for this option is:
4
when sending requests to a remote server, tell them we are running NTP protocol version ntpversion π¨
-r,--usereservedportβ use the NTP Reserved Port (port123). use port123, which is reserved for NTP, for our network communications π-S,--stepβ OK to 'step' the time withsettimeofday(2)π-s,--slewβ OK to 'slew' the time withadjtime(2)π (gentle. polite. smooth)-tseconds,--timeout=seconds β the number of seconds to wait for responses. this option takes an integer number as its argument. the default seconds for this option is:
5
when 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,--no-waitβ wait for pending replies (if not setting the time). theno-waitform will disable the option. this option is enabled by default. if we are not setting the time, wait for all pending responses π«Ά-?,--helpβ display usage information and exit π-!,--more-helpβ pass the extended usage information through a pager π->[cfgfile],--save-opts[=cfgfile] β save the option state to cfgfile. the default is the last configuration file listed in the OPTION PRESETS section, below. the command will exit after updating the config file πΎ-<cfgfile,--load-opts=cfgfile,--no-load-optsβ load options from cfgfile. theno-load-optsform will disable the loading of earlier config/rc/ini files.--no-load-optsis handled early, out of order π (yes, out of order. she's quirky like that)--version[{v|c|n}] β output version of program and exit. the default mode isv, a simple version. thecmode will print copyright information andnwill print the full copyright notice π·οΈ
π OPTION PRESETS π
any option that is not marked as not presettable may be preset by loading values from configuration ("RC" or ".INI") file(s) and values from environment variables named:
SNTP_<option-name> or SNTP
the 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 π
π USAGE π
π sntp ntpserver.somewhere
is the simplest use of this program and can be run as an unprivileged command to check the current time and error in the local clock π no root needed, she's lowkey chill
π sntp -Ss -M 128 ntpserver.somewhere
with suitable privilege, run as a command or from a cron(8) job, 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
with suitable privilege, run as a command or from a cron(8) job, sntp -S ntpserver.somewhere will set (step) the local clock from a synchronized specified server, like the (deprecated) ntpdate(1ntpdatemdoc), or rdate(8) commands π note the deprecated in there, bestie β that's not a vibe we're reviving
π§ ENVIRONMENT π§
see OPTION PRESETS for configuration environment variables π±
π§ FILES π§
see OPTION PRESETS for configuration files π
β EXIT STATUS β
one of the following exit values will be returned:
0(EXIT_SUCCESS) β successful program execution π1(EXIT_FAILURE) β the operation failed or the command syntax was not valid π66(EX_NOINPUT) β a specified configuration file could not be loaded π70(EX_SOFTWARE) βliboptshad an internal operational error. please report it toautogen-users@lists.sourceforge.net. thank you π«Ά
π AUTHORS π
- Johannes Maximilian Kuehn
- Harlan Stenn
- Dave Hart
icons, all of them π
πΈ COPYRIGHT πΈ
Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved. this program is released under the terms of the NTP license, <http://ntp.org/license> π
π¦ BUGS π¦
please send bug reports to: <https://bugs.ntp.org>, bugs@ntp.org π
β¨ NOTES β¨
this manual page was AutoGen-erated from the sntp option definitions π€ (yes, auto-generated, she's a machine-made icon and we respect that)
okay that's the whole page bestie, you're officially an SNTP scholar πβ¨ this was the Debian build of the SNTP(8) page, dated May 25 2024 β mwah, go query a server, love u, bye ππ«Άπ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms