I have NTP setup to run with GPSd and all is well. The issue arises after about a week of my raspberry pi being disconnected, NTP will trust the old date on the system clock. Since the GPS takes a couple seconds to get power and acquire a lock it seems like NTP will trust my local clock and never check the GPS again.
Interestingly if I run ntpq -p
I see:
SHM(0) .GPS. 0 l - 16 0 0.000 0.000 0.000
*LOCAL(0) .LOCL. 10 l 45 64 377 0.000 0.000 0.001
Then running the exact same command immediately after:
*SHM(0) .GPS. 0 l 1 16 0 0.000 9516243 0.001
LOCAL(0) .LOCL. 10 l 45 64 377 0.000 0.000 0.001
For some reason, although the GPS was online and reporting time, NTP never tried polling it again until after I ran ntpq -p
My config is as follows:
# WARNING: Disabling the panicgate is insecure when you don't fully trust your time calibrations. Since we are
# only using a GPS, this is okay.
tinker panic 0
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer
restrict -6 default kod nomodify notrap nopeer
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Only allow on our own network
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Read the rough GPS time from device 127.127.28.0
# Read the accurate PPS time from device 127.127.28.1
# The flag1 will allow skipping the time difference, see driver28 in NTP documentation:
# https://www.eecis.udel.edu/~mills/ntp/html/drivers/driver28.html
server 127.127.28.0 minpoll 4 maxpoll 4 iburst prefer
fudge 127.127.28.0 time1 0.535 refid GPS flag1 1
# Local clock backup
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
# Use servers from the ntp pool for the first synchronization,
# or as a backup if the GPS is disconnected
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org
# Ignore all other interfaces but itself
interface ignore wildcard
interface listen 127.0.0.1
interface listen ::1
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()βing
# it to the file.
driftfile /var/lib/ntp/drift
logfile /var/log/ntp.log
statsdir /var/log/ntp/
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
Any help would be greatly appreciated. I'm almost at the point of just having a cronjob run the command every so often so it gives the GPS a chance to respond.