How to get ntp to use gpsd to update system date/time with a large offset
Solution 1
I decided to go for a work-around... I used chrony.
Here is what I have in the config file at /etc/chrony/chrony.conf
to use the GPS as the reference clock (source):
refclock SHM 0
Then, to actually get chrony
to do large offset adjustments, instead of the normal gradual ones, I added this to the same config file:
makestep 1000 -1
That means that the step adjustment will happen when the hardware clock is off by at least a 1000 seconds. -1
means try as many times as it takes to get to match the reference clock.
I left the other settings intact, as provided by Debian Wheezy.
Solution 2
4 hours limit checking is implemented in ntpd/refclock_shm.c (ntp-4.2.8p7) and setting value '1' to flag1 in /etc/ntp.conf seems to stop this checking.
server 127.127.28.0 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.0 refid GPS stratum 4
fudge 127.127.28.0 time1 0.113 # coarse processing delay offset
fudge 127.127.28.0 flag1 1 # ignore difference limit
I am running ntpd 4.2.8p3 on a RaspberryPi.
Related videos on Youtube
tshepang
I do software development for a living and as a hobby. My favorite language is Rust, and I've used Python much in the past. My OS of choice is Debian.
Updated on September 18, 2022Comments
-
tshepang almost 2 years
I have a GPS connected to my system, and if I change system time to be ahead/behind GPS time by less than 4 hours,
ntpd
ensures that the system time is updated to match that of the GPS. If, however, that offset is beyond 4 hours, no update takes place.I have ensured to run
ntpd
with the-g
option, but it still doesn't work, unless I use normal ntp servers, for example havingserver 0.debian.pool.ntp.org iburst
in /etc/ntp.conf. Let us, however, assume that the system in question will not have internet access during normal operation.The other relevant settings in that file are:
server 127.127.28.0 minpoll 4 maxpoll 4 fudge 127.127.28.0 time1 0.420 refid GPS server 127.127.28.1 minpoll 4 maxpoll 4 prefer fudge 127.127.28.1 refid GPS1
(source:
gpsd
manpage)I even added
tinker panic 0
to that config, just to make sure, but still no luck.-
Admin over 11 yearsDid I get it correctly that you want to make it working without internet connectivity at all?
-
Admin over 11 yearsThat is correct.
-
-
grochmal over 7 yearsAlthough I have my concerns whether it is the same code of
ntpd
that may have been running in 2012 this likely does clear up from where the limit comes from (+1).