Sunday, May 16, 2021

NTP and hardware clock problem

 Two scripts run during boot and write headers to daily log files. Recently, the headers are not written but the data is logged.


The problem seems to be the NTP system time software. This software maintains and updates the system time and clock. An internet connection is required.

There is also a RTC hardware clock I have installed.

I am now testing to discover whether the NTP service is preventing the headers from being written.

In my theory, if there is a web connection when the Pi boots, there is no problem. Howerver, if there is no web connection, the NTP service prevents the first write to both log files, i.e. the headers.

Two options exist.

Turn off the NTP service and rely on the hardware clock I installed. The clock loses 63-110 seconds per year. If the battery goes bad, the time will be incorrect and log files will not be useful since the timestamp will be wrong. This is a major concern since the Pi is intended to run continuously, without interruption, and unmonitored. This option makes the Pi portable.

The second option is to make  sure the first boot of the Pi follows the web boot. Thus the headers are written. The NTP has no effect afterwards and no web connection is required. The NTP will automatically update when a web connection is detected.


Turn NTP on : sudo timedatectl set-ntp True

Check result with : timedatectl status

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home