xref: /freebsd/contrib/ntp/ntpd/invoke-ntpd.texi (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1@node ntpd Invocation
2@section Invoking ntpd
3@pindex ntpd
4@cindex NTP daemon program
5@ignore
6#
7# EDIT THIS FILE WITH CAUTION  (invoke-ntpd.texi)
8#
9# It has been AutoGen-ed  June 23, 2020 at 02:20:35 AM by AutoGen 5.18.5
10# From the definitions    ntpd-opts.def
11# and the template file   agtexi-cmd.tpl
12@end ignore
13
14
15
16The
17@code{ntpd}
18utility is an operating system daemon which sets
19and maintains the system time of day in synchronism with Internet
20standard time servers.
21It is a complete implementation of the
22Network Time Protocol (NTP) version 4, as defined by RFC-5905,
23but also retains compatibility with
24version 3, as defined by RFC-1305, and versions 1
25and 2, as defined by RFC-1059 and RFC-1119, respectively.
26
27The
28@code{ntpd}
29utility does most computations in 64-bit floating point
30arithmetic and does relatively clumsy 64-bit fixed point operations
31only when necessary to preserve the ultimate precision, about 232
32picoseconds.
33While the ultimate precision is not achievable with
34ordinary workstations and networks of today, it may be required
35with future gigahertz CPU clocks and gigabit LANs.
36
37Ordinarily,
38@code{ntpd}
39reads the
40@code{ntp.conf(5)}
41configuration file at startup time in order to determine the
42synchronization sources and operating modes.
43It is also possible to
44specify a working, although limited, configuration entirely on the
45command line, obviating the need for a configuration file.
46This may
47be particularly useful when the local host is to be configured as a
48broadcast/multicast client, with all peers being determined by
49listening to broadcasts at run time.
50
51If NetInfo support is built into
52@code{ntpd}
53then
54@code{ntpd}
55will attempt to read its configuration from the
56NetInfo if the default
57@code{ntp.conf(5)}
58file cannot be read and no file is
59specified by the
60@code{-c}
61option.
62
63Various internal
64@code{ntpd}
65variables can be displayed and
66configuration options altered while the
67@code{ntpd}
68is running
69using the
70@code{ntpq(1ntpqmdoc)}
71and
72@code{ntpdc(1ntpdcmdoc)}
73utility programs.
74
75When
76@code{ntpd}
77starts it looks at the value of
78@code{umask(2)},
79and if zero
80@code{ntpd}
81will set the
82@code{umask(2)}
83to 022.
84
85This section was generated by @strong{AutoGen},
86using the @code{agtexi-cmd} template and the option descriptions for the @code{ntpd} program.
87This software is released under the NTP license, <http://ntp.org/license>.
88
89@menu
90* ntpd usage::                  ntpd help/usage (@option{--help})
91* ntpd ipv4::                   ipv4 option (-4)
92* ntpd ipv6::                   ipv6 option (-6)
93* ntpd authreq::                authreq option (-a)
94* ntpd authnoreq::              authnoreq option (-A)
95* ntpd configfile::             configfile option (-c)
96* ntpd driftfile::              driftfile option (-f)
97* ntpd panicgate::              panicgate option (-g)
98* ntpd force-step-once::        force-step-once option (-G)
99* ntpd jaildir::                jaildir option (-i)
100* ntpd interface::              interface option (-I)
101* ntpd keyfile::                keyfile option (-k)
102* ntpd logfile::                logfile option (-l)
103* ntpd novirtualips::           novirtualips option (-L)
104* ntpd modifymmtimer::          modifymmtimer option (-M)
105* ntpd nice::                   nice option (-N)
106* ntpd pidfile::                pidfile option (-p)
107* ntpd priority::               priority option (-P)
108* ntpd quit::                   quit option (-q)
109* ntpd propagationdelay::       propagationdelay option (-r)
110* ntpd saveconfigquit::         saveconfigquit option
111* ntpd statsdir::               statsdir option (-s)
112* ntpd trustedkey::             trustedkey option (-t)
113* ntpd user::                   user option (-u)
114* ntpd updateinterval::         updateinterval option (-U)
115* ntpd wait-sync::              wait-sync option (-w)
116* ntpd slew::                   slew option (-x)
117* ntpd usepcc::                 usepcc option
118* ntpd pccfreq::                pccfreq option
119* ntpd mdns::                   mdns option (-m)
120* ntpd config::                 presetting/configuring ntpd
121* ntpd exit status::            exit status
122* ntpd Usage::                  Usage
123* ntpd Files::                  Files
124* ntpd See Also::               See Also
125* ntpd Bugs::                   Bugs
126* ntpd Notes::                  Notes
127@end menu
128
129@node ntpd usage
130@subsection ntpd help/usage (@option{--help})
131@cindex ntpd help
132
133This is the automatically generated usage text for ntpd.
134
135The text printed is the same whether selected with the @code{help} option
136(@option{--help}) or the @code{more-help} option (@option{--more-help}).  @code{more-help} will print
137the usage text by passing it through a pager program.
138@code{more-help} is disabled on platforms without a working
139@code{fork(2)} function.  The @code{PAGER} environment variable is
140used to select the program, defaulting to @file{more}.  Both will exit
141with a status code of 0.
142
143@exampleindent 0
144@example
145ntpd - NTP daemon program - Ver. 4.2.8p15
146Usage:  ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
147                [ <server1> ... <serverN> ]
148  Flg Arg Option-Name    Description
149   -4 no  ipv4           Force IPv4 DNS name resolution
150                                - prohibits the option 'ipv6'
151   -6 no  ipv6           Force IPv6 DNS name resolution
152                                - prohibits the option 'ipv4'
153   -a no  authreq        Require crypto authentication
154                                - prohibits the option 'authnoreq'
155   -A no  authnoreq      Do not require crypto authentication
156                                - prohibits the option 'authreq'
157   -b no  bcastsync      Allow us to sync to broadcast servers
158   -c Str configfile     configuration file name
159   -d no  debug-level    Increase debug verbosity level
160                                - may appear multiple times
161   -D Num set-debug-level Set the debug verbosity level
162                                - may appear multiple times
163   -f Str driftfile      frequency drift file name
164   -g no  panicgate      Allow the first adjustment to be Big
165                                - may appear multiple times
166   -G no  force-step-once Step any initial offset correction.
167   -i --- jaildir        built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
168   -I Str interface      Listen on an interface name or address
169                                - may appear multiple times
170   -k Str keyfile        path to symmetric keys
171   -l Str logfile        path to the log file
172   -L no  novirtualips   Do not listen to virtual interfaces
173   -n no  nofork         Do not fork
174                                - prohibits the option 'wait-sync'
175   -N no  nice           Run at high priority
176   -p Str pidfile        path to the PID file
177   -P Num priority       Process priority
178   -q no  quit           Set the time and quit
179                                - prohibits these options:
180                                saveconfigquit
181                                wait-sync
182   -r Str propagationdelay Broadcast/propagation delay
183      Str saveconfigquit Save parsed configuration and quit
184                                - prohibits these options:
185                                quit
186                                wait-sync
187   -s Str statsdir       Statistics file location
188   -t Str trustedkey     Trusted key number
189                                - may appear multiple times
190   -u --- user           built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
191   -U Num updateinterval interval in seconds between scans for new or dropped interfaces
192      Str var            make ARG an ntp variable (RW)
193                                - may appear multiple times
194      Str dvar           make ARG an ntp variable (RW|DEF)
195                                - may appear multiple times
196   -w Num wait-sync      Seconds to wait for first clock sync
197                                - prohibits these options:
198                                nofork
199                                quit
200                                saveconfigquit
201   -x no  slew           Slew up to 600 seconds
202      opt version        output version information and exit
203   -? no  help           display extended usage information and exit
204   -! no  more-help      extended usage information passed thru pager
205
206Options are specified by doubled hyphens and their name or by a single
207hyphen and the flag character.
208
209
210The following option preset mechanisms are supported:
211 - examining environment variables named NTPD_*
212
213Please send bug reports to:  <http://bugs.ntp.org, bugs@@ntp.org>
214@end example
215@exampleindent 4
216
217@node ntpd ipv4
218@subsection ipv4 option (-4)
219@cindex ntpd-ipv4
220
221This is the ``force ipv4 dns name resolution'' option.
222
223@noindent
224This option has some usage constraints.  It:
225@itemize @bullet
226@item
227must not appear in combination with any of the following options:
228ipv6.
229@end itemize
230
231Force DNS resolution of following host names on the command line
232to the IPv4 namespace.
233@node ntpd ipv6
234@subsection ipv6 option (-6)
235@cindex ntpd-ipv6
236
237This is the ``force ipv6 dns name resolution'' option.
238
239@noindent
240This option has some usage constraints.  It:
241@itemize @bullet
242@item
243must not appear in combination with any of the following options:
244ipv4.
245@end itemize
246
247Force DNS resolution of following host names on the command line
248to the IPv6 namespace.
249@node ntpd authreq
250@subsection authreq option (-a)
251@cindex ntpd-authreq
252
253This is the ``require crypto authentication'' option.
254
255@noindent
256This option has some usage constraints.  It:
257@itemize @bullet
258@item
259must not appear in combination with any of the following options:
260authnoreq.
261@end itemize
262
263Require cryptographic authentication for broadcast client,
264multicast client and symmetric passive associations.
265This is the default.
266@node ntpd authnoreq
267@subsection authnoreq option (-A)
268@cindex ntpd-authnoreq
269
270This is the ``do not require crypto authentication'' option.
271
272@noindent
273This option has some usage constraints.  It:
274@itemize @bullet
275@item
276must not appear in combination with any of the following options:
277authreq.
278@end itemize
279
280Do not require cryptographic authentication for broadcast client,
281multicast client and symmetric passive associations.
282This is almost never a good idea.
283@node ntpd configfile
284@subsection configfile option (-c)
285@cindex ntpd-configfile
286
287This is the ``configuration file name'' option.
288This option takes a string argument.
289The name and path of the configuration file,
290@file{/etc/ntp.conf}
291by default.
292@node ntpd driftfile
293@subsection driftfile option (-f)
294@cindex ntpd-driftfile
295
296This is the ``frequency drift file name'' option.
297This option takes a string argument.
298The name and path of the frequency file,
299@file{/etc/ntp.drift}
300by default.
301This is the same operation as the
302@code{driftfile} @kbd{driftfile}
303configuration specification in the
304@file{/etc/ntp.conf}
305file.
306@node ntpd panicgate
307@subsection panicgate option (-g)
308@cindex ntpd-panicgate
309
310This is the ``allow the first adjustment to be big'' option.
311
312@noindent
313This option has some usage constraints.  It:
314@itemize @bullet
315@item
316may appear an unlimited number of times.
317@end itemize
318
319Normally,
320@code{ntpd}
321exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that,
322@code{ntpd}
323will exit with a message to the system log. This option can be used with the
324@code{-q}
325and
326@code{-x}
327options.
328See the
329@code{tinker}
330configuration file directive for other options.
331@node ntpd force-step-once
332@subsection force-step-once option (-G)
333@cindex ntpd-force-step-once
334
335This is the ``step any initial offset correction.'' option.
336Normally,
337@code{ntpd}
338steps the time if the time offset exceeds the step threshold,
339which is 128 ms by default, and otherwise slews the time.
340This option forces the initial offset correction to be stepped,
341so the highest time accuracy can be achieved quickly.
342However, this may also cause the time to be stepped back
343so this option must not be used if
344applications requiring monotonic time are running.
345See the @code{tinker} configuration file directive for other options.
346@node ntpd jaildir
347@subsection jaildir option (-i)
348@cindex ntpd-jaildir
349
350This is the ``jail directory'' option.
351This option takes a string argument.
352
353@noindent
354This option has some usage constraints.  It:
355@itemize @bullet
356@item
357must be compiled in by defining @code{HAVE_DROPROOT} during the compilation.
358@end itemize
359
360Chroot the server to the directory
361@kbd{jaildir}
362.
363This option also implies that the server attempts to drop root privileges at startup.
364You may need to also specify a
365@code{-u}
366option.
367This option is only available if the OS supports adjusting the clock
368without full root privileges.
369This option is supported under NetBSD (configure with
370@code{--enable-clockctl}) or Linux (configure with
371@code{--enable-linuxcaps}) or Solaris (configure with @code{--enable-solarisprivs}).
372@node ntpd interface
373@subsection interface option (-I)
374@cindex ntpd-interface
375
376This is the ``listen on an interface name or address'' option.
377This option takes a string argument @file{iface}.
378
379@noindent
380This option has some usage constraints.  It:
381@itemize @bullet
382@item
383may appear an unlimited number of times.
384@end itemize
385
386Open the network address given, or all the addresses associated with the
387given interface name.  This option may appear multiple times.  This option
388also implies not opening other addresses, except wildcard and localhost.
389This option is deprecated. Please consider using the configuration file
390@code{interface} command, which is more versatile.
391@node ntpd keyfile
392@subsection keyfile option (-k)
393@cindex ntpd-keyfile
394
395This is the ``path to symmetric keys'' option.
396This option takes a string argument.
397Specify the name and path of the symmetric key file.
398@file{/etc/ntp.keys}
399is the default.
400This is the same operation as the
401@code{keys} @kbd{keyfile}
402configuration file directive.
403@node ntpd logfile
404@subsection logfile option (-l)
405@cindex ntpd-logfile
406
407This is the ``path to the log file'' option.
408This option takes a string argument.
409Specify the name and path of the log file.
410The default is the system log file.
411This is the same operation as the
412@code{logfile} @kbd{logfile}
413configuration file directive.
414@node ntpd novirtualips
415@subsection novirtualips option (-L)
416@cindex ntpd-novirtualips
417
418This is the ``do not listen to virtual interfaces'' option.
419Do not listen to virtual interfaces, defined as those with
420names containing a colon.  This option is deprecated.  Please
421consider using the configuration file @code{interface} command, which
422is more versatile.
423@node ntpd modifymmtimer
424@subsection modifymmtimer option (-M)
425@cindex ntpd-modifymmtimer
426
427This is the ``modify multimedia timer (windows only)'' option.
428
429@noindent
430This option has some usage constraints.  It:
431@itemize @bullet
432@item
433must be compiled in by defining @code{SYS_WINNT} during the compilation.
434@end itemize
435
436Set the Windows Multimedia Timer to highest resolution.  This
437ensures the resolution does not change while ntpd is running,
438avoiding timekeeping glitches associated with changes.
439@node ntpd nice
440@subsection nice option (-N)
441@cindex ntpd-nice
442
443This is the ``run at high priority'' option.
444To the extent permitted by the operating system, run
445@code{ntpd}
446at the highest priority.
447@node ntpd pidfile
448@subsection pidfile option (-p)
449@cindex ntpd-pidfile
450
451This is the ``path to the pid file'' option.
452This option takes a string argument.
453Specify the name and path of the file used to record
454@code{ntpd}'s
455process ID.
456This is the same operation as the
457@code{pidfile} @kbd{pidfile}
458configuration file directive.
459@node ntpd priority
460@subsection priority option (-P)
461@cindex ntpd-priority
462
463This is the ``process priority'' option.
464This option takes a number argument.
465To the extent permitted by the operating system, run
466@code{ntpd}
467at the specified
468@code{sched_setscheduler(SCHED_FIFO)}
469priority.
470@node ntpd quit
471@subsection quit option (-q)
472@cindex ntpd-quit
473
474This is the ``set the time and quit'' option.
475
476@noindent
477This option has some usage constraints.  It:
478@itemize @bullet
479@item
480must not appear in combination with any of the following options:
481saveconfigquit, wait-sync.
482@end itemize
483
484@code{ntpd}
485will not daemonize and will exit after the clock is first
486synchronized.  This behavior mimics that of the
487@code{ntpdate}
488program, which will soon be replaced with a shell script.
489The
490@code{-g}
491and
492@code{-x}
493options can be used with this option.
494Note: The kernel time discipline is disabled with this option.
495@node ntpd propagationdelay
496@subsection propagationdelay option (-r)
497@cindex ntpd-propagationdelay
498
499This is the ``broadcast/propagation delay'' option.
500This option takes a string argument.
501Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
502@node ntpd saveconfigquit
503@subsection saveconfigquit option
504@cindex ntpd-saveconfigquit
505
506This is the ``save parsed configuration and quit'' option.
507This option takes a string argument.
508
509@noindent
510This option has some usage constraints.  It:
511@itemize @bullet
512@item
513must be compiled in by defining @code{SAVECONFIG} during the compilation.
514@item
515must not appear in combination with any of the following options:
516quit, wait-sync.
517@end itemize
518
519Cause @code{ntpd} to parse its startup configuration file and save an
520equivalent to the given filename and exit.  This option was
521designed for automated testing.
522@node ntpd statsdir
523@subsection statsdir option (-s)
524@cindex ntpd-statsdir
525
526This is the ``statistics file location'' option.
527This option takes a string argument.
528Specify the directory path for files created by the statistics facility.
529This is the same operation as the
530@code{statsdir} @kbd{statsdir}
531configuration file directive.
532@node ntpd trustedkey
533@subsection trustedkey option (-t)
534@cindex ntpd-trustedkey
535
536This is the ``trusted key number'' option.
537This option takes a string argument @file{tkey}.
538
539@noindent
540This option has some usage constraints.  It:
541@itemize @bullet
542@item
543may appear an unlimited number of times.
544@end itemize
545
546Add the specified key number to the trusted key list.
547@node ntpd user
548@subsection user option (-u)
549@cindex ntpd-user
550
551This is the ``run as userid (or userid:groupid)'' option.
552This option takes a string argument.
553
554@noindent
555This option has some usage constraints.  It:
556@itemize @bullet
557@item
558must be compiled in by defining @code{HAVE_DROPROOT} during the compilation.
559@end itemize
560
561Specify a user, and optionally a group, to switch to.
562This option is only available if the OS supports adjusting the clock
563without full root privileges.
564This option is supported under NetBSD (configure with
565@code{--enable-clockctl}) or Linux (configure with
566@code{--enable-linuxcaps}) or Solaris (configure with @code{--enable-solarisprivs}).
567@node ntpd updateinterval
568@subsection updateinterval option (-U)
569@cindex ntpd-updateinterval
570
571This is the ``interval in seconds between scans for new or dropped interfaces'' option.
572This option takes a number argument.
573Give the time in seconds between two scans for new or dropped interfaces.
574For systems with routing socket support the scans will be performed shortly after the interface change
575has been detected by the system.
576Use 0 to disable scanning. 60 seconds is the minimum time between scans.
577@node ntpd wait-sync
578@subsection wait-sync option (-w)
579@cindex ntpd-wait-sync
580
581This is the ``seconds to wait for first clock sync'' option.
582This option takes a number argument.
583
584@noindent
585This option has some usage constraints.  It:
586@itemize @bullet
587@item
588must be compiled in by defining @code{HAVE_WORKING_FORK} during the compilation.
589@item
590must not appear in combination with any of the following options:
591nofork, quit, saveconfigquit.
592@end itemize
593
594If greater than zero, alters @code{ntpd}'s behavior when forking to
595daemonize.  Instead of exiting with status 0 immediately after
596the fork, the parent waits up to the specified number of
597seconds for the child to first synchronize the clock.  The exit
598status is zero (success) if the clock was synchronized,
599otherwise it is @code{ETIMEDOUT}.
600This provides the option for a script starting @code{ntpd} to easily
601wait for the first set of the clock before proceeding.
602@node ntpd slew
603@subsection slew option (-x)
604@cindex ntpd-slew
605
606This is the ``slew up to 600 seconds'' option.
607Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
608This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.
609Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.
610Thus, an adjustment as much as 600 s will take almost 14 days to complete.
611This option can be used with the
612@code{-g}
613and
614@code{-q}
615options.
616See the
617@code{tinker}
618configuration file directive for other options.
619Note: The kernel time discipline is disabled with this option.
620@node ntpd usepcc
621@subsection usepcc option
622@cindex ntpd-usepcc
623
624This is the ``use cpu cycle counter (windows only)'' option.
625
626@noindent
627This option has some usage constraints.  It:
628@itemize @bullet
629@item
630must be compiled in by defining @code{SYS_WINNT} during the compilation.
631@end itemize
632
633Attempt to substitute the CPU counter for @code{QueryPerformanceCounter}.
634The CPU counter and @code{QueryPerformanceCounter} are compared, and if
635they have the same frequency, the CPU counter (RDTSC on x86) is
636used directly, saving the overhead of a system call.
637@node ntpd pccfreq
638@subsection pccfreq option
639@cindex ntpd-pccfreq
640
641This is the ``force cpu cycle counter use (windows only)'' option.
642This option takes a string argument.
643
644@noindent
645This option has some usage constraints.  It:
646@itemize @bullet
647@item
648must be compiled in by defining @code{SYS_WINNT} during the compilation.
649@end itemize
650
651Force substitution the CPU counter for @code{QueryPerformanceCounter}.
652The CPU counter (RDTSC on x86) is used unconditionally with the
653given frequency (in Hz).
654@node ntpd mdns
655@subsection mdns option (-m)
656@cindex ntpd-mdns
657
658This is the ``register with mdns as a ntp server'' option.
659
660@noindent
661This option has some usage constraints.  It:
662@itemize @bullet
663@item
664must be compiled in by defining @code{HAVE_DNSREGISTRATION} during the compilation.
665@end itemize
666
667Registers as an NTP server with the local mDNS server which allows
668the server to be discovered via mDNS client lookup.
669
670
671@node ntpd config
672@subsection presetting/configuring ntpd
673
674Any option that is not marked as @i{not presettable} may be preset by
675loading values from environment variables named @code{NTPD} and @code{NTPD_<OPTION_NAME>}.  @code{<OPTION_NAME>} must be one of
676the options listed above in upper case and segmented with underscores.
677The @code{NTPD} variable will be tokenized and parsed like
678the command line.  The remaining variables are tested for existence and their
679values are treated like option arguments.
680
681
682The command line options relating to configuration and/or usage help are:
683
684@subsubheading version (-)
685
686Print the program version to standard out, optionally with licensing
687information, then exit 0.  The optional argument specifies how much licensing
688detail to provide.  The default is to print just the version.  The licensing infomation may be selected with an option argument.
689Only the first letter of the argument is examined:
690
691@table @samp
692@item version
693Only print the version.  This is the default.
694@item copyright
695Name the copyright usage licensing terms.
696@item verbose
697Print the full copyright usage licensing terms.
698@end table
699
700@node ntpd exit status
701@subsection ntpd exit status
702
703One of the following exit values will be returned:
704@table @samp
705@item 0 (EXIT_SUCCESS)
706Successful program execution.
707@item 1 (EXIT_FAILURE)
708The operation failed or the command syntax was not valid.
709@end table
710@node ntpd Usage
711@subsection ntpd Usage
712@node ntpd Files
713@subsection ntpd Files
714@node ntpd See Also
715@subsection ntpd See Also
716@node ntpd Bugs
717@subsection ntpd Bugs
718@node ntpd Notes
719@subsection ntpd Notes
720