sntp(1)
π sntp(1) β the manual, but make it make sense β¨
okay so bestie, you're looking at sntp, and yes it's literally the standard Simple Network Time Protocol client program β the manual page is sntp(1), and no I will not be normal about it π«Ά
πΈ NAME πΈ
sntp β the standard SNTP client program, aka your little time-gremlin that asks a server what time it is π
π¦ SYNOPSIS π¦
sntp [-flags] [-flag [value]] [--option-name[[=| ]value]] [ hostname-or-IP ...]
β¨ DESCRIPTION β¨
So sntp is an SNTP client: you point it at an NTP or SNTP server and it will either display the time or set the local system's time (and for that second one you need suitable privilege, no cap π). You can run it interactively, or from a cron job β she's flexible like that π
NTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol) are defined and described by RFC 5905.
By default it writes the estimated correct local date and time (i.e. not UTC, okay, local) to standard output, in a format like this:
1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN
Let me break that down because it's giving lore drop π:
(+0800)means that to get to UTC from the reported local time you must add 8 hours and 0 minutes.+4.567means the local clock is 4.567 seconds behind the correct time (so 4.567 seconds must be added to the local clock to make it correct). The number of decimals printed for this value will change based on the reported precision of the server β she keeps it precise π+/- 0.089is the reported synchronization distance in seconds, which represents the maximum error due to all causes. If the server doesn't report the valid data needed to calculate the synchronization distance, this shows up as+/- ?(mystery era π).- If the host is different from the IP, both get displayed. Otherwise, only the IP is displayed.
- Finally, the stratum of the host is reported, and the leap indicator is decoded and displayed. slay.
π OPTIONS π
-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.-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.-a auth-keynumber,--authentication=auth-keynumberβ Enable authentication with the keyauth-keynumber. This option takes an integer number as its argument. The argument of this option is the keyid, a number specified in the keyfile as this key's identifier. See thekeyfileoption (-k) for more details π-b broadcast-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.-c host-name,--concurrent=host-nameβ Concurrently query all IPs returned forhost-name. This option may appear an unlimited number of times. 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 suppliedhost-nameare on different machines, so we can send concurrent queries πββοΈπ¨-d,--debug-levelβ Increase debug verbosity level. This option may appear an unlimited number of times.-D number,--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.-g milliseconds,--gap=millisecondsβ The gap (in milliseconds) between time requests. This option takes an integer number as its argument. The defaultmillisecondsfor 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 β±οΈ
-K file-name,--kod=file-nameβ KoD history filename. The defaultfile-namefor 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 π
-k file-name,--keyfile=file-nameβ Look in this file for the key specified with-a. The defaultfile-namefor 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 π
-l file-name,--logfile=file-nameβ Log to specified logfile. This option causes the client to write log messages to the specifiedlogfile.-M number,--steplimit=numberβ Adjustments less thansteplimitmsec will be slewed. This option takes an integer number as its argument. The value ofnumberis 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 π«
-o number,--ntpversion=numberβ Sendintas our NTP protocol version. This option takes an integer number as its argument. The value ofnumberis 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).-t seconds,--timeout=secondsβ The number of seconds to wait for responses. This option takes an integer number as its argument. The defaultsecondsfor 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 tocfgfile. 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 fromcfgfile. Theno-load-optsform will disable the loading of earlier config/rc/ini files.--no-load-optsis handled early, out of order π«--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 πΈ
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(1) or rdate(8) commands. (deprecated!! we said it!! β οΈ)
π§ 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
π 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, "AutoGen-erated", that's literally what it says, iconic honestly β¨)
and that's the whole page bestie!! this beauty is from 4.2.8p18, dated 25 May 2024 β go forth and sync your clocks, you absolute main character π¦π
π¦ where this page comes from
- arch rolling: ntp 4.2.8.p18-6 Β· custom
- nixos 26.05: ntp 4.2.8p18
- nixpkgs unstable: ntp 4.2.8p18
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms