I've got a 64-bit Intel PC running Debian 8 with a capacitor-based clock, which means after 3 days without power the time is lost from the hardware clock. To help work-around this, I was thinking we could use a nearby computer on the LAN (with a better battery-backed RTC) to act as a local NTP server.
On boot, will the PC be able to perform an NTP sync fast enough that by the time the "normal" applications start up (esp. our user applications) they are using the correct time, and we aren't dealing with time discontinuities? Our primary function is data logging, so if we started a log file as 1970 and then had it leap to 2016 that would be catastrophic.
Best Answer
There are two things you should do. Make sure
ntpd
is started as early as possible in the boot sequence, and put anntp-wait
somewhere in the boot sequence before any of your applications start.Depending on your version of Linux, how you achieve that will vary. You should, however, make your application startup dependant on the
ntp-wait
finishing.ntp-wait
simply waits for thentpd
daemon to report it is synced.The right way to do this on Debian 8 would be to configure
systemd
, and to add a new service for thentp-wait
, which your applications would then be dependant upon.The easy way to do it, is put an
ntp-wait
in the startup scripts for your apps.