我使用一个Raspberry Pi 3,并需要更新时间通过ntp后,重新启动系统。
应该使用dhcp通过wifi更新。一般来说,它可以工作,但同步需要大约。半小时后我不明白为什么。
当我想手动启动ntp服务时
>>sudo /etc/init.d/ntp restart它说“好”,但是系统什么也不做--错误的时间还在RTC上。
你有什么想法,有什么问题吗?
另一个信息是,Pi在只读mode...but中运行,如果它没有写访问就不能工作--半小时后不会更新,不是吗?
要完成我的问题,这里的问题是ntp.conf:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
Driftfile /var/lib/ntp/ntp.drift
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
...
Server 0.de.pool.ntp.org iburst
Server 1.de.pool.ntp.org iburst
Server 2.de.pool.ntp.org iburst
Server 3.de.pool.ntp.org iburst
Server 127.127.1.0 #local clock
Fudge 127.127.1.0 stratum 10
...来扩展我对我的项目的解释。我想使用Pi作为NTP服务器。第一个问题是RTC在重新启动或Pi关闭后“跑掉”--特别是在较长的时间内。这就是为什么我有一个想法,Pi应该是一个NTP客户端在第一次设置RTC,然后Pi需要是一个NTP服务器的设备,这是通过以太与Pi连接。所以我通过Wifi连接Pi来得到当前的时间。正如我已经说过的一般情况下,这是可行的,但它需要太多的时间。
然后,我想用我之前发布的命令手动进行同步。我的想法是作为一个cron作业来执行这个任务,但是还有一个问题: 1. Pi忽略了命令;2. cronjob也被忽略,或者在重新启动后被删除。
但是我想一步一步地走,我想要解决的第一个问题是减少同步时间。
我希望你现在对我的情况有一个更好的了解.
你需要更多的细节吗?
好的,我现在有了我想要的解决方案,但是有一种行为,我不明白。配置是正确的。但是,我使用车载WiFi通过ntp.conf中配置的NTP服务器同步系统时间。我使用以太网(有线局域网)作为RPi有线设备的NTP服务器。在这里,IP设置:
WLAN (DHCP): 192.168.1.x
Ethernet (static): 192.168.10.10我把这两个接口放在不同的网络中,因为否则只有一个连接可以工作--但为什么要这样呢?这是主要的问题,为什么同步花了这么长时间。当我用本地时钟注释掉这一行时
Server 127.127.1.0那么网络上的同步就会立即生效..。为什么会发生这种事?
发布于 2018-01-13 11:25:43
rpi没有RTC,因此它总是在1970年1月1日启动--将服务器和NTP缓慢和递增地同步的时间更长;因此,在NTP和系统之间的差异得到纠正之前,NTP默认不会正常运行。
我将添加到您的ntp.conf文件中作为第一行(它必须是第一行):
tinker panic 0此设置建议用于VM和物联网设备。
修补程序恐慌--以秒为单位指定默认1000 s的恐慌阈值。如果设置为零,则将禁用恐慌状态检查,并接受任意值的时钟偏移量。
我也会考虑购买一个RTC,因为它是便宜的,特别是如果你打算有项目没有互联网连接。请参阅时钟无法打开rtc文件
发布于 2018-12-20 17:33:05
这个问题是通过在/etc/ntp.conf中的模糊行中添加"flag1 1“来解决的。我们用全球定位系统来确定时间。如果系统时钟电池耗尽,系统将不会在正确的时间启动。我们需要NTP尽快修复它。这是我们的/etc/ntp.conf文件:
# "flag1 1" means skip the difference limit check and fix the time even if it is far off.
# If the battery for the system clock fails the system clock will start with a default time.
# The date will be years off, more than the sanity check limit, we need for ntp to correct the time anyway.
#
# GPS Serial data reference
server 127.127.28.0 minpoll 4 maxpoll 4 true
fudge 127.127.28.0 time1 0.0 refid GPS flag1 1
# GPS PPS reference
server 127.127.28.1 minpoll 4 maxpoll 4 prefer true
fudge 127.127.28.1 refid PPS flag1 1
driftfile /var/lib/ntp/drift
# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
# Allow unrestricted acces from the localhost
restrict 127.0.0.1 mask 255.255.255.0
restrict -6 ::1
# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day disable
filegen clockstats file clockstats type day enable我在这里找到了这个解决方案:NTP文档
发布于 2018-01-14 16:37:33
使用ntpdate实用程序作为一次引导实用程序,使时钟足够接近ntpd来管理。
如果您的发行版有它,请检查这个按时间顺序排列的RPM包;它比传统的NTP更容易管理。
https://unix.stackexchange.com/questions/416774
复制相似问题