用 systemsetup 设置网络时间服务器
用 systemsetup 在终端里为 Mac 指定 NTP 时间服务器并开启自动校时。
运行 sudo systemsetup -setnetworktimeserver time.apple.com,再运行 sudo systemsetup -setusingnetworktime on 即可开启网络校时。
01命令
命令
$ sudo systemsetup -setnetworktimeserver time.apple.com && sudo systemsetup -setusingnetworktime on02作用说明
macOS 通过查询 NTP(网络时间协议)服务器来自动校准时钟,systemsetup 可以用脚本同时设置服务器地址和开关。这在不易操作日期与时间设置面板的机器、刚部署好的新 Mac、或公司有自建时间服务器时特别有用。时钟不准会导致浏览器、App Store 证书报错,修复校时往往也能一并解决这些问题。
03风险
!注意: systemsetup 需要 sudo 权限;某些 macOS 版本通过 SSH 执行时可能受限。如果指定的服务器连不上,时钟就不再自动校准——除非确实有自建 NTP 服务器,否则保持 time.apple.com 即可。
04撤销
撤销
$ sudo systemsetup -setusingnetworktime off05来源
- systemsetup - Configure Machine Settings依据: Documents systemsetup -setnetworktimeserver and -setusingnetworktime for configuring the NTP server and automatic time sync.
最后验证: 2026-09-18 · 分类: 系统与设置