用 systemsetup 设置网络时间服务器

用 systemsetup 在终端里为 Mac 指定 NTP 时间服务器并开启自动校时。

macOSsystemsetup 系统设置时间NTP 时间同步中风险
运行 sudo systemsetup -setnetworktimeserver time.apple.com,再运行 sudo systemsetup -setusingnetworktime on 即可开启网络校时。

01命令

命令
$ sudo systemsetup -setnetworktimeserver time.apple.com && sudo systemsetup -setusingnetworktime on

02作用说明

macOS 通过查询 NTP(网络时间协议)服务器来自动校准时钟,systemsetup 可以用脚本同时设置服务器地址和开关。这在不易操作日期与时间设置面板的机器、刚部署好的新 Mac、或公司有自建时间服务器时特别有用。时钟不准会导致浏览器、App Store 证书报错,修复校时往往也能一并解决这些问题。

03风险

风险中风险
使用条件Requires administrator (sudo) privileges; on newer macOS the command prints a notice directing you to System Settings, but still applies.
!注意: systemsetup 需要 sudo 权限;某些 macOS 版本通过 SSH 执行时可能受限。如果指定的服务器连不上,时钟就不再自动校准——除非确实有自建 NTP 服务器,否则保持 time.apple.com 即可。

04撤销

撤销
$ sudo systemsetup -setusingnetworktime off

05来源

  • systemsetup - Configure Machine Settings
    SS64 · technical · 2026-09-17
    依据: Documents systemsetup -setnetworktimeserver and -setusingnetworktime for configuring the NTP server and automatic time sync.

最后验证: 2026-09-18 · 分类: 系统与设置