我已设置 NTP 以与 GPSd 一起运行,一切正常。问题出现在我的 Raspberry Pi 断开连接约一周后,NTP 将信任系统时钟上的旧日期。由于 GPS 需要几秒钟才能获得电源并获取锁定,因此 NTP 似乎会信任我的本地时钟并且永远不会再检查 GPS。
有趣的是,如果我运行,ntpq -p
我会看到:
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
然后立即运行完全相同的命令:
*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
出于某种原因,尽管 GPS 在线并报告时间,但 NTP 从未尝试再次轮询它,直到我运行ntpq -p
我的配置如下:
# 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
任何帮助都将不胜感激。我几乎已经到了只让 cronjob 每隔一段时间运行命令的阶段,这样它就让 GPS 有机会做出响应。