您尚未登录。

#1 2021-04-16 16:42:01

chen05_20
会员
注册时间: 2021-04-02
帖子: 123

时间同步问题

1.timedatectl set-ntp true 重启后变为false
2.对于一些限制端口的wifi, set-ntp true后 更新的时间仅在当前系统生效,无法写入硬件时钟
此时手动更新时间 ntpdate xxxx 报以下错误
no server suitable for synchronization found

离线

#2 2021-04-16 16:55:46

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: 时间同步问题

1. 安装 ntp 并 systemctl enable --now ntpd

离线

#3 2021-04-17 09:49:01

chen05_20
会员
注册时间: 2021-04-02
帖子: 123

Re: 时间同步问题

依云 说:

1. 安装 ntp 并 systemctl enable --now ntpd

这个更新的机制是什么,好像一开始不会更新,过了一段时候才能更新,另外这个时间还是没存到硬件时钟里面

另外每次重启都会有以下错误  kernel reports TIME_ERROR: 0x41: Clock Unsynchronized

4月 17 11:09:02 cm-pc ntpd[7954]: proto: precision = 0.042 usec (-24)
4月 17 11:09:02 cm-pc ntpd[7954]: basedate set to 2020-06-19
4月 17 11:09:02 cm-pc ntpd[7954]: gps base set to 2020-06-21 (week 2111)
4月 17 11:09:02 cm-pc ntpd[7954]: Listen and drop on 0 v4wildcard 0.0.0.0:123
4月 17 11:09:02 cm-pc ntpd[7954]: Listen normally on 1 lo 127.0.0.1:123
4月 17 11:09:02 cm-pc ntpd[7954]: Listen normally on 2 wlp0s20f3 192.168.43.43:123
4月 17 11:09:02 cm-pc ntpd[7954]: Listening on routing socket on fd #19 for interface updates
4月 17 11:09:02 cm-pc ntpd[7954]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
4月 17 11:09:02 cm-pc ntpd[7954]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized

最近编辑记录 chen05_20 (2021-04-17 11:11:52)

离线

#4 2021-04-17 14:12:10

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: 时间同步问题

「另外这个时间还是没存到硬件时钟里面」——说清楚一些,具体是什么表现?没存进去那么你的硬件时钟的时间是什么时候?

离线

#5 2021-04-18 09:19:36

chen05_20
会员
注册时间: 2021-04-02
帖子: 123

Re: 时间同步问题

依云 说:

「另外这个时间还是没存到硬件时钟里面」——说清楚一些,具体是什么表现?没存进去那么你的硬件时钟的时间是什么时候?

我启动了ntpd进程后一段时间后系统时间更新了,但是我timedatectl

               Local time: 日 2021-04-18 09:17:40 CST
           Universal time: 日 2021-04-18 01:17:40 UTC
                 RTC time: 日 2021-04-18 06:49:46
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

RTC time 仍然没有变,重启后又变成了硬件原本的时间

离线

#6 2021-04-18 13:57:11

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: 时间同步问题

哦,就是系统时间没能同步到 rtc 上。这种情况我也没遇到过。
你试试用 hwclock 命令手工同步,能同步上么?

离线

#7 2021-04-18 15:41:42

chen05_20
会员
注册时间: 2021-04-02
帖子: 123

Re: 时间同步问题

依云 说:

哦,就是系统时间没能同步到 rtc 上。这种情况我也没遇到过。
你试试用 hwclock 命令手工同步,能同步上么?

可以,这个ntpd进程有什么钩子么?我想让它每次更新完执行到RTC。

离线

#8 2021-04-18 16:12:48

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: 时间同步问题

这个时间应该是自动同步的呀。
ntptime 显示什么?你用的是什么内核?

离线

#9 2021-04-20 09:52:03

chen05_20
会员
注册时间: 2021-04-02
帖子: 123

Re: 时间同步问题

依云 说:

这个时间应该是自动同步的呀。
ntptime 显示什么?你用的是什么内核?

ntp_gettime() returns code 5 (ERROR)
  time e428b222.d28d3000  Tue, Apr 20 2021  9:51:30.822, (.822467),
  maximum error 16000000 us, estimated error 16000000 us, TAI offset 0
ntp_adjtime() returns code 5 (ERROR)
  modes 0x0 (),
  offset 0.000 us, frequency 0.000 ppm, interval 1 s,
  maximum error 16000000 us, estimated error 16000000 us,
  status 0x4041 (PLL,UNSYNC,MODE),
  time constant 7, precision 1.000 us, tolerance 500 ppm,




Linux cm-pc 5.11.13-arch1-1 #1 SMP PREEMPT Sat, 10 Apr 2021 20:47:14 +0000 x86_64 GNU/Linux

离线

#10 2021-04-20 13:26:18

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: 时间同步问题

嗯,它就是没同步到硬件时钟。我也不知道为什么。需要的话可以自己调 hwclock 同步。

离线

页脚