]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - usr.sbin/ntp/doc/sntp.8
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / usr.sbin / ntp / doc / sntp.8
1 .Dd February 4 2015
2 .Dt SNTP 8 User Commands
3 .Os
4 .\"  EDIT THIS FILE WITH CAUTION  (sntp-opts.mdoc)
5 .\"
6 .\" $FreeBSD$
7 .\"
8 .\"  It has been AutoGen-ed  February  4, 2015 at 02:34:20 AM by AutoGen 5.18.5pre4
9 .\"  From the definitions    sntp-opts.def
10 .\"  and the template file   agmdoc-cmd.tpl
11 .Sh NAME
12 .Nm sntp
13 .Nd standard Simple Network Time Protocol client program
14 .Sh SYNOPSIS
15 .Nm
16 .\" Mixture of short (flag) options and long options
17 .Op Fl flags
18 .Op Fl flag Op Ar value
19 .Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc
20 [ hostname\-or\-IP ...]
21 .Pp
22 .Sh DESCRIPTION
23 .Nm
24 can be used as an SNTP client to query a NTP or SNTP server and either display
25 the time or set the local system's time (given suitable privilege).  It can be
26 run as an interactive command or from a
27 .Ic cron
28 job.
29 NTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol)
30 are defined and described by RFC 5905.
31 .Pp
32 The default is to write the estimated correct local date and time (i.e. not
33 UTC) to the standard output in a format like:
34 .Ic "'1996\-10\-15 20:17:25.123 (+0800) +4.567 +/\- 0.089 [host] IP sN'"
35 where the
36 .Ic "'(+0800)'"
37 means that to get to UTC from the reported local time one must
38 add 8 hours and 0 minutes,
39 the
40 .Ic "'+4.567'"
41 indicates the local clock is 4.567 seconds behind the correct time
42 (so 4.567 seconds must be added to the local clock to get it to be correct).
43 Note that the number of decimals printed for this value will change
44 based on the reported precision of the server.
45 .Ic "'+/\- 0.089'"
46 is the reported
47 .Em synchronization distance
48 (in seconds), which represents the maximum error due to all causes.
49 If the server does not report valid data needed to calculate the
50 synchronization distance, this will be reported as
51 .Ic "'+/\- ?'" .
52 If the
53 .Em host
54 is different from the
55 .Em IP ,
56 both will be displayed.
57 Otherwise, only the 
58 .Em IP
59 is displayed.
60 Finally, the
61 .Em stratum
62 of the host is reported.
63 .Sh "OPTIONS"
64 .Bl -tag
65 .It  Fl 4 , Fl \-ipv4 
66 Force IPv4 DNS name resolution.
67 This option must not appear in combination with any of the following options:
68 ipv6.
69 .sp
70 Force DNS resolution of the following host names on the command line
71 to the IPv4 namespace.
72 .It  Fl 6 , Fl \-ipv6 
73 Force IPv6 DNS name resolution.
74 This option must not appear in combination with any of the following options:
75 ipv4.
76 .sp
77 Force DNS resolution of the following host names on the command line
78 to the IPv6 namespace.
79 .It  Fl a Ar auth\-keynumber , Fl \-authentication Ns = Ns Ar auth\-keynumber 
80 Enable authentication with the key \fBauth\-keynumber\fP.
81 This option takes an integer number as its argument.
82 .sp
83 Enable authentication using the key specified in this option's
84 argument.  The argument of this option is the \fBkeyid\fP, a
85 number specified in the \fBkeyfile\fP as this key's identifier.
86 See the \fBkeyfile\fP option (\fB\-k\fP) for more details.
87 .It  Fl b Ar broadcast\-address , Fl \-broadcast Ns = Ns Ar broadcast\-address 
88 Listen to the address specified for broadcast time sync.
89 This option may appear an unlimited number of times.
90 .sp
91 If specified \fBsntp\fP will listen to the specified address
92 for NTP broadcasts.  The default maximum wait time
93 can (and probably should) be modified with \fB\-t\fP.
94 .It  Fl c Ar host\-name , Fl \-concurrent Ns = Ns Ar host\-name 
95 Concurrently query all IPs returned for host\-name.
96 This option may appear an unlimited number of times.
97 .sp
98 Requests from an NTP "client" to a "server" should never be sent
99 more rapidly than one every 2 seconds.  By default, any IPs returned
100 as part of a DNS lookup are assumed to be for a single instance of
101 \fBntpd\fP, and therefore \fBsntp\fP will send queries to these IPs
102 one after another, with a 2\-second gap in between each query.
103 .sp
104 The \fB\-c\fP or \fB\-\-concurrent\fP flag says that any IPs
105 returned for the DNS lookup of the supplied host\-name are on
106 different machines, so we can send concurrent queries.
107 .It  Fl d , Fl \-debug\-level 
108 Increase debug verbosity level.
109 This option may appear an unlimited number of times.
110 .sp
111 .It  Fl D Ar number , Fl \-set\-debug\-level Ns = Ns Ar number 
112 Set the debug verbosity level.
113 This option may appear an unlimited number of times.
114 This option takes an integer number as its argument.
115 .sp
116 .It  Fl g Ar milliseconds , Fl \-gap Ns = Ns Ar milliseconds 
117 The gap (in milliseconds) between time requests.
118 This option takes an integer number as its argument.
119 The default
120 .Ar milliseconds
121 for this option is:
122 .ti +4
123  50
124 .sp
125 Since we're only going to use the first valid response we get and
126 there is benefit to specifying a good number of servers to query,
127 separate the queries we send out by the specified number of
128 milliseconds.
129 .It  Fl K Ar file\-name , Fl \-kod Ns = Ns Ar file\-name 
130 KoD history filename.
131 The default
132 .Ar file\-name
133 for this option is:
134 .ti +4
135  /var/db/ntp\-kod
136 .sp
137 Specifies the filename to be used for the persistent history of KoD
138 responses received from servers.  If the file does not exist, a
139 warning message will be displayed.  The file will not be created.
140 .It  Fl k Ar file\-name , Fl \-keyfile Ns = Ns Ar file\-name 
141 Look in this file for the key specified with \fB\-a\fP.
142 .sp
143 This option specifies the keyfile.
144 \fBsntp\fP will search for the key specified with \fB\-a\fP
145 \fIkeyno\fP in this file.  See \fBntp.keys(5)\fP for more
146 information.
147 .It  Fl l Ar file\-name , Fl \-logfile Ns = Ns Ar file\-name 
148 Log to specified logfile.
149 .sp
150 This option causes the client to write log messages to the specified
151 \fIlogfile\fP.
152 .It  Fl M Ar number , Fl \-steplimit Ns = Ns Ar number 
153 Adjustments less than \fBsteplimit\fP msec will be slewed.
154 This option takes an integer number as its argument.
155 The value of
156 .Ar number
157 is constrained to being:
158 .in +4
159 .nf
160 .na
161 greater than or equal to 0
162 .fi
163 .in -4
164 .sp
165 If the time adjustment is less than \fIsteplimit\fP milliseconds,
166 slew the amount using \fBadjtime(2)\fP.  Otherwise, step the
167 correction using \fBsettimeofday(2)\fP.  The default value is 0,
168 which means all adjustments will be stepped.  This is a feature, as
169 different situations demand different values.
170 .It  Fl o Ar number , Fl \-ntpversion Ns = Ns Ar number 
171 Send \fBint\fP as our NTP protocol version.
172 This option takes an integer number as its argument.
173 The value of
174 .Ar number
175 is constrained to being:
176 .in +4
177 .nf
178 .na
179 in the range  0 through 7
180 .fi
181 .in -4
182 The default
183 .Ar number
184 for this option is:
185 .ti +4
186  4
187 .sp
188 When sending requests to a remote server, tell them we are running
189 NTP protocol version \fIntpversion\fP .
190 .It  Fl r , Fl \-usereservedport 
191 Use the NTP Reserved Port (port 123).
192 .sp
193 Use port 123, which is reserved for NTP, for our network
194 communications.
195 .It  Fl S , Fl \-step 
196 OK to 'step' the time with \fBsettimeofday(2)\fP.
197 .sp
198 .It  Fl s , Fl \-slew 
199 OK to 'slew' the time with \fBadjtime(2)\fP.
200 .sp
201 .It  Fl t Ar seconds , Fl \-timeout Ns = Ns Ar seconds 
202 The number of seconds to wait for responses.
203 This option takes an integer number as its argument.
204 The default
205 .Ar seconds
206 for this option is:
207 .ti +4
208  5
209 .sp
210 When waiting for a reply, \fBsntp\fP will wait the number
211 of seconds specified before giving up.  The default should be
212 more than enough for a unicast response.  If \fBsntp\fP is
213 only waiting for a broadcast response a longer timeout is
214 likely needed.
215 .It  Fl \-wait , " Fl \-no\-wait"
216 Wait for pending replies (if not setting the time).
217 The \fIno\-wait\fP form will disable the option.
218 This option is enabled by default.
219 .sp
220 If we are not setting the time, wait for all pending responses.
221 .It Fl \&? , Fl \-help
222 Display usage information and exit.
223 .It Fl \&! , Fl \-more\-help
224 Pass the extended usage information through a pager.
225 .It Fl > Oo Ar cfgfile Oc , Fl \-save\-opts Oo Ns = Ns Ar cfgfile Oc
226 Save the option state to \fIcfgfile\fP.  The default is the \fIlast\fP
227 configuration file listed in the \fBOPTION PRESETS\fP section, below.
228 The command will exit after updating the config file.
229 .It Fl < Ar cfgfile , Fl \-load\-opts Ns = Ns Ar cfgfile , Fl \-no\-load\-opts
230 Load options from \fIcfgfile\fP.
231 The \fIno\-load\-opts\fP form will disable the loading
232 of earlier config/rc/ini files.  \fI\-\-no\-load\-opts\fP is handled early,
233 out of order.
234 .It Fl \-version Op Brq Ar v|c|n
235 Output version of program and exit.  The default mode is `v', a simple
236 version.  The `c' mode will print copyright information and `n' will
237 print the full copyright notice.
238 .El
239 .Sh "OPTION PRESETS"
240 Any option that is not marked as \fInot presettable\fP may be preset
241 by loading values from configuration ("RC" or ".INI") file(s) and values from
242 environment variables named:
243 .nf
244   \fBSNTP_<option\-name>\fP or \fBSNTP\fP
245 .fi
246 .ad
247 The environmental presets take precedence (are processed later than)
248 the configuration files.
249 The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
250 If any of these are directories, then the file \fI.ntprc\fP
251 is searched for within those directories.
252 .Sh USAGE
253 .Bl -tag -width indent
254 .It Li "sntp ntpserver.somewhere"
255 is the simplest use of this program
256 and can be run as an unprivileged command
257 to check the current time and error in the local clock.
258 .It Li "sntp \-Ss \-M 128 ntpserver.somewhere"
259 With suitable privilege,
260 run as a command
261 or from a
262 .Xr cron 8
263 job,
264 .Ic "sntp \-Ss \-M 128 ntpserver.somewhere"
265 will request the time from the server,
266 and if that server reports that it is synchronized
267 then if the offset adjustment is less than 128 milliseconds
268 the correction will be slewed,
269 and if the correction is more than 128 milliseconds
270 the correction  will be stepped.
271 .It Li "sntp \-S ntpserver.somewhere"
272 With suitable privilege,
273 run as a command
274 or from a
275 .Xr cron 8
276 job,
277 .Ic "sntp \-S ntpserver.somewhere"
278 will set (step) the local clock from a synchronized specified server,
279 like the (deprecated)
280 .Xr ntpdate 8 ,
281 or
282 .Xr rdate 8
283 commands.
284 .El
285 .Sh "ENVIRONMENT"
286 See \fBOPTION PRESETS\fP for configuration environment variables.
287 .Sh "FILES"
288 See \fBOPTION PRESETS\fP for configuration files.
289 .Sh "EXIT STATUS"
290 One of the following exit values will be returned:
291 .Bl -tag
292 .It 0 " (EXIT_SUCCESS)"
293 Successful program execution.
294 .It 1 " (EXIT_FAILURE)"
295 The operation failed or the command syntax was not valid.
296 .It 66 " (EX_NOINPUT)"
297 A specified configuration file could not be loaded.
298 .It 70 " (EX_SOFTWARE)"
299 libopts had an internal operational error.  Please report
300 it to autogen\-users@lists.sourceforge.net.  Thank you.
301 .El
302 .Sh AUTHORS
303 .An "Johannes Maximilian Kuehn"
304 .An "Harlan Stenn"
305 .An "Dave Hart"
306 .Sh "COPYRIGHT"
307 Copyright (C) 1992\-2015 The University of Delaware and Network Time Foundation all rights reserved.
308 This program is released under the terms of the NTP license, <http://ntp.org/license>.
309 .Sh "BUGS"
310 Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
311 .Sh "NOTES"
312 This manual page was \fIAutoGen\fP\-erated from the \fBsntp\fP
313 option definitions.