閱讀61 返回首頁    go 阿裏雲 go 技術社區[雲棲]


mac OS X 從無法同步互聯網時間想到的

    最近在mac OS X 巨浪 :)上執行 

ntpdate time.nist.gov

    失敗,提示 13 Jan 19:41:53 ntpdate[1374]: the NTP socket is in use, exiting

顯然是端口被ntpd服務占用了,無法同步,用sudo root也不行。查看進程:

apple@kissAir: LaunchDaemons$ps aux|grep ntpd
root             1332   0.0  0.0  2469104   1464   ??  Ss    7:41下午   0:00.02 /usr/sbin/ntpd -c /private/etc/ntp-restrict.conf -n -g -p /var/run/ntpd.pid -f /var/db/ntp.drift

使用sudo killall ntpd強關無效,該服務立即restart,很頑強啊。

使用launchctl list 查看服務表,找到該服務,使用 sudo launchctl stop org.ntp.ntpd

無效,該服務依然自動重啟。

遂使用sudo launchctl remove org.ntp.ntpd將其刪掉,接下來ntpdate成功:

apple@kissAir: LaunchDaemons$sudo ntpdate time.nist.gov
13 Jan 19:36:54 ntpdate[1189]: adjust time server 216.171.120.36 offset 0.021011 sec

但是launchctl表裏該服務沒有了,所以得加上!使用mdfind查看ntpd位置,然後用load加上吧:

sudo launchctl load /System/Library/LaunchDaemons/org.ntp.ntpd.plist
然後重新start服務即可:

sudo launchctl start org.ntp.ntpd

大笑

最後更新:2017-04-03 12:54:31

  上一篇:go linux網卡驅動源碼分析
  下一篇:go ASI通訊協議——ASI2x1