1sntp(8) User Commands sntp(8)
2
3
4
6 sntp - standard Simple Network Time Protocol client program
7
9 sntp [-flags] [-flag [value]] [--option-name[[=| ]value]] [ hostname-
10 or-IP ...]
11
12
14 sntp can be used as an SNTP client to query a NTP or SNTP server and
15 either display the time or set the local system's time (given suitable
16 privilege). It can be run as an interactive command or from a cron
17 job. NTP (the Network Time Protocol) and SNTP (the Simple Network Time
18 Protocol) are defined and described by RFC 5905.
19
20 The default is to write the estimated correct local date and time (i.e.
21 not UTC) to the standard output in a format like: '1996-10-15
22 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN' where the '(+0800)'
23 means that to get to UTC from the reported local time one must add 8
24 hours and 0 minutes, the '+4.567' indicates the local clock is 4.567
25 seconds behind the correct time (so 4.567 seconds must be added to the
26 local clock to get it to be correct). Note that the number of decimals
27 printed for this value will change based on the reported precision of
28 the server. '+/- 0.089' is the reported synchronization distance (in
29 seconds), which represents the maximum error due to all causes. If the
30 server does not report valid data needed to calculate the synchroniza‐
31 tion distance, this will be reported as '+/- ?'. If the host is dif‐
32 ferent from the IP, both will be displayed. Otherwise, only the IP is
33 displayed. Finally, the stratum of the host is reported and the leap
34 indicator is decoded and displayed.
35
37 -4, --ipv4
38 Force IPv4 DNS name resolution. This option must not appear in
39 combination with any of the following options: ipv6.
40
41 Force DNS resolution of the following host names on the command
42 line to the IPv4 namespace.
43
44 -6, --ipv6
45 Force IPv6 DNS name resolution. This option must not appear in
46 combination with any of the following options: ipv4.
47
48 Force DNS resolution of the following host names on the command
49 line to the IPv6 namespace.
50
51 -a auth-keynumber, --authentication=auth-keynumber
52 Enable authentication with the key auth-keynumber. This option
53 takes an integer number as its argument.
54
55 Enable authentication using the key specified in this option's
56 argument. The argument of this option is the keyid, a number
57 specified in the keyfile as this key's identifier. See the key‐
58 file option (-k) for more details.
59
60 -b broadcast-address, --broadcast=broadcast-address
61 Listen to the address specified for broadcast time sync. This
62 option may appear an unlimited number of times.
63
64 If specified sntp will listen to the specified address for NTP
65 broadcasts. The default maximum wait time can (and probably
66 should) be modified with -t.
67
68 -c host-name, --concurrent=host-name
69 Concurrently query all IPs returned for host-name. This option
70 may appear an unlimited number of times.
71
72 Requests from an NTP "client" to a "server" should never be sent
73 more rapidly than one every 2 seconds. By default, any IPs
74 returned as part of a DNS lookup are assumed to be for a single
75 instance of ntpd, and therefore sntp will send queries to these
76 IPs one after another, with a 2-second gap in between each
77 query.
78
79 The -c or --concurrent flag says that any IPs returned for the
80 DNS lookup of the supplied host-name are on different machines,
81 so we can send concurrent queries.
82
83 -d, --debug-level
84 Increase debug verbosity level. This option may appear an
85 unlimited number of times.
86
87
88 -D number, --set-debug-level=number
89 Set the debug verbosity level. This option may appear an unlim‐
90 ited number of times. This option takes an integer number as
91 its argument.
92
93
94 -g milliseconds, --gap=milliseconds
95 The gap (in milliseconds) between time requests. This option
96 takes an integer number as its argument. The default millisec‐
97 onds for this option is:
98 50
99
100 Since we're only going to use the first valid response we get
101 and there is benefit to specifying a good number of servers to
102 query, separate the queries we send out by the specified number
103 of milliseconds.
104
105 -K file-name, --kod=file-name
106 KoD history filename. The default file-name for this option is:
107 /var/lib/sntp/kod
108
109 Specifies the filename to be used for the persistent history of
110 KoD responses received from servers. If the file does not
111 exist, a warning message will be displayed. The file will not
112 be created.
113
114 -k file-name, --keyfile=file-name
115 Look in this file for the key specified with -a. The default
116 file-name for this option is:
117 /etc/ntp.keys
118
119 This option specifies the keyfile. sntp will search for the key
120 specified with -a keyno in this file. See ntp.keys(5) for more
121 information.
122
123 -l file-name, --logfile=file-name
124 Log to specified logfile.
125
126 This option causes the client to write log messages to the spec‐
127 ified logfile.
128
129 -M number, --steplimit=number
130 Adjustments less than steplimit msec will be slewed. This
131 option takes an integer number as its argument. The value of
132 number is constrained to being:
133 greater than or equal to 0
134
135 If the time adjustment is less than steplimit milliseconds, slew
136 the amount using adjtime(2). Otherwise, step the correction
137 using settimeofday(2). The default value is 0, which means all
138 adjustments will be stepped. This is a feature, as different
139 situations demand different values.
140
141 -o number, --ntpversion=number
142 Send int as our NTP protocol version. This option takes an
143 integer number as its argument. The value of number is con‐
144 strained to being:
145 in the range 0 through 7
146 The default number for this option is:
147 4
148
149 When sending requests to a remote server, tell them we are run‐
150 ning NTP protocol version ntpversion .
151
152 -r, --usereservedport
153 Use the NTP Reserved Port (port 123).
154
155 Use port 123, which is reserved for NTP, for our network commu‐
156 nications.
157
158 -S, --step
159 OK to 'step' the time with settimeofday(2).
160
161
162 -s, --slew
163 OK to 'slew' the time with adjtime(2).
164
165
166 -t seconds, --timeout=seconds
167 The number of seconds to wait for responses. This option takes
168 an integer number as its argument. The default seconds for this
169 option is:
170 5
171
172 When waiting for a reply, sntp will wait the number of seconds
173 specified before giving up. The default should be more than
174 enough for a unicast response. If sntp is only waiting for a
175 broadcast response a longer timeout is likely needed.
176
177 --wait, - Fl -no-wait
178 Wait for pending replies (if not setting the time). The no-wait
179 form will disable the option. This option is enabled by
180 default.
181
182 If we are not setting the time, wait for all pending responses.
183
184 -?, --help
185 Display usage information and exit.
186
187 -!, --more-help
188 Pass the extended usage information through a pager.
189
190 -> [cfgfile], --save-opts [=cfgfile]
191 Save the option state to cfgfile. The default is the last con‐
192 figuration file listed in the OPTION PRESETS section, below.
193 The command will exit after updating the config file.
194
195 -< cfgfile, --load-opts=cfgfile, --no-load-opts
196 Load options from cfgfile. The no-load-opts form will disable
197 the loading of earlier config/rc/ini files. --no-load-opts is
198 handled early, out of order.
199
200 --version [{v|c|n}]
201 Output version of program and exit. The default mode is `v', a
202 simple version. The `c' mode will print copyright information
203 and `n' will print the full copyright notice.
204
206 Any option that is not marked as not presettable may be preset by load‐
207 ing values from configuration ("RC" or ".INI") file(s) and values from
208 environment variables named:
209 SNTP_<option-name> or SNTP
210 The environmental presets take precedence (are processed later than)
211 the configuration files. The homerc files are "$HOME", and ".". If
212 any of these are directories, then the file .ntprc is searched for
213 within those directories.
214
216 sntp ntpserver.somewhere
217 is the simplest use of this program and can be run as an unpriv‐
218 ileged command to check the current time and error in the local
219 clock.
220
221 sntp -Ss -M 128 ntpserver.somewhere
222 With suitable privilege, run as a command or from a cron(8) job,
223 sntp -Ss -M 128 ntpserver.somewhere will request the time from
224 the server, and if that server reports that it is synchronized
225 then if the offset adjustment is less than 128 milliseconds the
226 correction will be slewed, and if the correction is more than
227 128 milliseconds the correction will be stepped.
228
229 sntp -S ntpserver.somewhere
230 With suitable privilege, run as a command or from a cron(8) job,
231 sntp -S ntpserver.somewhere will set (step) the local clock from
232 a synchronized specified server, like the (deprecated) ntp‐
233 date(8), or rdate(8) commands.
234
236 See OPTION PRESETS for configuration environment variables.
237
239 See OPTION PRESETS for configuration files.
240
242 One of the following exit values will be returned:
243
244 0 (EXIT_SUCCESS)
245 Successful program execution.
246
247 1 (EXIT_FAILURE)
248 The operation failed or the command syntax was not valid.
249
250 66 (EX_NOINPUT)
251 A specified configuration file could not be loaded.
252
253 70 (EX_SOFTWARE)
254 libopts had an internal operational error. Please report it to
255 autogen-users@lists.sourceforge.net. Thank you.
256
258 Johannes Maximilian Kuehn
259 Harlan Stenn
260 Dave Hart
261
263 Copyright (C) 1992-2017 The University of Delaware and Network Time
264 Foundation all rights reserved. This program is released under the
265 terms of the NTP license, <http://ntp.org/license>.
266
268 Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
269
271 This manual page was AutoGen-erated from the sntp option definitions.
272
273
274
2754.2.8p13 20 Feb 2019 sntp(8)