Score:-1

How to determine if NTP has updated the time

us flag

I am on a Raspberry Pi and have a service that wants to know how inaccurate (ie - number of seconds) the system time is if the system time is off by at least one minute. When Raspberry Pi starts up, NTP has already updated the time before my service has a chance to start. How would I accomplish this?

I have tried updating /etc/ntp.conf by enabling statsdir:

statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

I believe clockstats should contain a record whenever the clock has updated. I however do not see /var/log/ntpstats/clockstats after I power off my Raspberry Pi for 5 minutes, and turn it back on.

Score:0
us flag

I am parsing syslog for "Time has been changed" and compared the timestamps:

grep "Time has been changed" \var\log\syslog -a -B1 | tail -n 2
Score:0
nc flag

I think NTP will actually crash if the clock is off by a whole minute. NTP wants to keep the clock within subsecond accuracy.

There are options to ntpd to allow it to jump the clock at startup, but even that does not work well if it has to jump the clock by a large amount. I believe the default ntp startup script tries to quickly set the time from one of the ntp sources before starting ntpd. I have had to modify my pi's ntp boot script to use other methods to set the clock within a few seconds of accuracy to get ntpd to start. (Specifically, it waits for the GPS to get a lock and then sets the time from the gps, but this is a special case, as I needed to be able to start ntpd without a working internet connection.)

You can also check the accuracy of the system clock vs. various sources with the command ntpq -np

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.