首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >NTPd不同步在RaspberryPi上

NTPd不同步在RaspberryPi上
EN

Unix & Linux用户
提问于 2014-08-01 12:09:20
回答 1查看 721关注 0票数 2

由于我的硬件(RasberryPi)没有硬件时钟,每次启动都会使我们回到1970年的S,所以我使用NTP。我所在的网络上的网关提供了NTP-Server服务。

我的/etc/ntp.conf看起来像折叠(注释行省略)

代码语言:javascript
复制
server 192.168.170.254 //gateway that hosts the service
driftfile /var/lib/ntp/ntp.drift

/etc/profile

代码语言:javascript
复制
[connect wifi...]
timeout 15 ntpd -q -g //forces update so I have a time to work with, times out so I don't get a total hang if it doesn't work
systemctl start ntpd.service //in hopes that I will work at some point and to keep it in sync
date //see if it worked
[start main program...]

我是不是遗漏了什么?

编辑

ntpd -q的输出:

代码语言:javascript
复制
DEC 31 17:00:43 alarmpi ntpd[349]: ntpd 4.2.7p446@1.2483-o Wed Jul  2 03:23:39 UTC 2014 (1): Starting
DEC 31 17:00:43 alarmpi ntpd[349]: Command line: /usr/bin/ntpd -q
DEC 31 17:00:43 alarmpi ntpd[349]: proto: precision = 3000 usec (-18)
DEC 31 17:00:43 alarmpi ntpd[349]: Listen and drop on 0 v4wildcard 0.0.0.0:123
DEC 31 17:00:43 alarmpi ntpd[349]: Listen normally on 1 lo 127.0.0.1:123
DEC 31 17:00:43 alarmpi ntpd[349]: Listen normally on 2 wlan0 192.168.170.100:123
DEC 31 17:00:43 alarmpi ntpd[349]: Listening on routing socket on fd #19 for interface updates
#hangs here till interrupted

systemctl status ntpd的输出:

代码语言:javascript
复制
* ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled)
Active: active (running) since Wed 1969-12-31 17:00:43 MST, 16s ago
Process: 332 ExecStart=/usr/bin/ntpd -g -u ntp:ntp -p /run/ntpd.pid (code=exited, status=0/SUCCESS)
Main PID: 335 (ntpd)
CGroup: /system.slice/ntpd.service
        `-335 /usr/bin/ntpd -g -u ntp:ntp -p /run/ntpd.pid

DEC 31 17:00:43 alarmpi ntpd[332]: ntpd 4.2.7p446@1.2483-o Wed Jul  2 03:23:39 UTC 2014 (1): Starting
DEC 31 17:00:43 alarmpi ntpd[332]: Command line: /usr/bin/ntpd -g -u ntp:ntp -q /run/ntpd.pid
DEC 31 17:00:43 alarmpi systemd[1]: PID file /run/ntpd.pid not readable (yet?) after start.
DEC 31 17:00:43 alarmpi ntpd[335]: proto: precision = 3000 usec (-18)
DEC 31 17:00:43 alarmpi ntpd[335]: Listen and drop on 0 v4wildcard 0.0.0.0:123
DEC 31 17:00:43 alarmpi ntpd[335]: Listen normally on 1 lo 127.0.0.1:123
DEC 31 17:00:43 alarmpi ntpd[335]: Listen normally on 2 wlan0 192.168.170.100:123
DEC 31 17:00:43 alarmpi ntpd[335]: Listening on routing socket on fd #19 for interface updates
DEC 31 17:00:43 alarmpi systemd[1]: Started Network Time Service
EN

回答 1

Unix & Linux用户

发布于 2015-05-11 01:39:34

@asonwryan对另一个问题的回答为这个问题提供了一个很好的解决方案。硬件问题(缺乏实时时钟)使得这有点困难。

如果RaspberryPi缺乏RTC,我建议您确保使用一个可以将最后一次存储到磁盘的工具,然后在引导时引用该工具将时钟从UNIX时间的黎明中提取出来。结合使用系统d-时间同步,在/etc/systemd/timesyncd.conf中为首选的时间服务器提供一个可选的配置文件,系统d-网络d将在启动时迅速启动网络,并尽早纠正时钟中的任何偏差。守护进程随后将定期同步时钟(大约每30分钟一次)。

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/147850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档