macOS ntp not working


我的老macbook pro总是时不时跟ntp服务器对不上时间,少的时候差几秒,多的时候几分钟。之前root下 crontab 每小时跟aliyun ntp对时,结果这次怎么执行都会偏差两秒,连续sntp也还是两秒。

1 mac 同步时间使用 sntp,命令格式

sudo sntp -sS ntp.ntsc.ac.cn

2 sntp的输出可以使用 -d 来看到 debug log,基本格式是

+2.017470 +/- 0.000153 ntp.ntsc.ac.cn 114.118.7.161

上边是我的输出,我连续执行1 的命令,每次第一列都是2秒左右,开 -d 可以看到解释

ipaddr:         114.118.7.163
+2.020197 +/- 0.069878 ntp.ntsc.ac.cn 114.118.7.163
  gtod:  1633021695.100748
adjust:           2.020196
   set:  1633021697.120944

快速解决方案,把timed kill掉,再sntp同步,就好了。

稳定解决方案,暂无。

长期不稳定但有效的解决方案,写脚本,连续 n 次采样偏差,自动杀 timed,反正系统自己会起。


Leave a Reply

Your email address will not be published. Required fields are marked *