htpdate不会更新时间。

huangapple go评论61阅读模式
英文:

htpdate does not update time

问题

我有两台机器,一台是Rpi4,另一台是Ubuntu PC。这两台机器都是离网的,并连接到它们各自的网络。我的想法是将RPi4的时间与Ubuntu机器同步。由于端口和防火墙问题,NTP方法失败了,所以我改用htpdate。然而,我注意到无论使用什么命令,都无法消除时间偏移。

我在其他地方寻找了如何同步的方法,但没有成功:

  1. 在两台Linux机器之间同步时间
  2. 如何同步树莓派系统时钟
  3. 如何知道htpdate是否已同步系统时钟
  4. htpdate.8.en.html
  5. htpdate.php

问题是我无法消除时间偏移。我的会话输出如下:

pi@CMPL01-003-21:~ $ sudo htpdate -qd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1                 80 14 Feb 2023 13:37:24 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1                 80 14 Feb 2023 13:37:25 GMT (0.006) => 38
#: 1 mean: 38 average: 38.000
Offset 38.000 seconds
poll 1800 s

pi@CMPL01-003-21:~ $ sudo htpdate -xqd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1                 80 14 Feb 2023 13:39:25 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1                 80 14 Feb 2023 13:39:26 GMT (0.003) => 38
#: 1 mean: 38 average: 38.000
Adjusting 38.000 seconds
poll 1800 s

pi@CMPL01-003-21:~ $ sudo htpdate -sd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1                 80 14 Feb 2023 13:40:26 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1                 80 14 Feb 2023 13:40:27 GMT (0.005) => 38
#: 1 mean: 38 average: 38.000
Setting 38.000 seconds
Set: Tue Feb 14 14:40:27 2023
poll 1800 s

是否有遗漏的隐藏的htpdate参数或者一些要应用于文件夹的规则以清除偏移?

英文:

I have two machines, a Rpi4 and Ubuntu PC. The two machines are offgrid and connected to their network. The idea is to sync the RPi4 time with the Ubuntu machine. The NTP aproach failed because port and firewall issues. So I used htpdate instead. I've noticed however that I can not set the correct system time of the Rpi4. Regardless of the command I can not get rid of the offset.

I looked elsewhere on how to sync without success:

  1. synchronising-time-between-two-linux-machines
  2. how-to-sync-raspberry-pi-system-clock
  3. how-to-know-if-htpdate-has-synchronized-system-clock
  4. htpdate.8.en.html
  5. htpdate.php

The problem is I can not get rid of the offset. The output of my sessions are:

pi@CMPL01-003-21:~ $ sudo htpdate -qd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1                 80 14 Feb 2023 13:37:24 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1                 80 14 Feb 2023 13:37:25 GMT (0.006) => 38
#: 1 mean: 38 average: 38.000
Offset 38.000 seconds
poll 1800 s

pi@CMPL01-003-21:~ $ sudo htpdate -xqd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1                 80 14 Feb 2023 13:39:25 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1                 80 14 Feb 2023 13:39:26 GMT (0.003) => 38
#: 1 mean: 38 average: 38.000
Adjusting 38.000 seconds
poll 1800 s

pi@CMPL01-003-21:~ $ sudo htpdate -sd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1                 80 14 Feb 2023 13:40:26 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1                 80 14 Feb 2023 13:40:27 GMT (0.005) => 38
#: 1 mean: 38 average: 38.000
Setting 38.000 seconds
Set: Tue Feb 14 14:40:27 2023
poll 1800 s

Is there a missing hidden htpdate parameter or some rules to apply to a folder maybe to clear the offset?

答案1

得分: 1

我升级了htpdate的版本,从1.2.0升级到1.3.7,然后再次尝试。结果是一样的,偏移仍然存在,不同之处在于命令输出指出客户机正在运行自动的NTP同步服务。之后,我成功地使用htpdate进行同步,通过使用sudo timedatectl set-ntp false禁用了该服务。案件已结。

英文:

I upgraded the version of htpdate from 1.2.0 to 1.3.7 and tried again. The result was the same and the offset was still there with the difference that the command output noted the client machine was running the automatic ntp sync service. Afterward I was able to sync correctly with htpdate after disabling the service with sudo timedatectl set-ntp false. Case closed.

huangapple
  • 本文由 发表于 2023年2月14日 22:12:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75449065.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定