On Sat, 13 Aug 2016 10:37:36 -0700
Rick Moen <rick@???> wrote:
> The default window is not hours but rather 1000 seconds. _But_ there
> is an override, the '-g' switch to ntpd. Thus: 'ntpd -q -g'
> Quoting the manpage:
>
> -g Normally, ntpd exits 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, ntpd will exit with a
> message to the system log. This option can be used with the -q and -x
> options.
>
> -q Exit the ntpd just after the first time the clock is
> set. This behavior mimics that of the ntpdate program, which is to be
> retired. The -g and -x options can be used with this
> option. Note: The kernel time discipline is disabled with this
> option.
This is pretty cool.
So if I have a laptop I haven't fired up in a year, and its time is
either erased or off by more than 1000 seconds, no sweat, I just do
ntpd -q -p
and I bootstrap myself to the correct time, after which I can restart
ntpd with my init system or process supervisor. Or, if for some reason
I'm still using a computer that forgets time when shut off, even though
I've replaced the cmos battery, I could put a run-once ntpd -q -p early
in the boot just after the network comes up, and run respawning ntpd
some time after.
Or buy another computer.
Thanks,
SteveT
Steve Litt
August 2016 featured book: Manager's Guide to Technical Troubleshooting
Brand new, second edition
http://www.troubleshooters.com/mgr