用 systemsetup 设置 Mac 空闲休眠时间
在命令行精确设定 Mac 空闲多少分钟后休眠,并随时读回当前值,适合批量管理。
执行 sudo systemsetup -setcomputersleep 15 让 Mac 空闲 15 分钟后休眠;设为 0 表示永不休眠。
01命令
命令
$ sudo systemsetup -setcomputersleep 15 && sudo systemsetup -getcomputersleep02作用说明
systemsetup 相当于节能面板的脚本化版本,写入的是同一个空闲计时器,但可以通过 SSH 远程批量执行,特别适合机房或无头 Mac mini。-getcomputersleep 会返回当前分钟数方便确认;0 则完全关闭空闲休眠。
03风险
!注意: 在 Apple Silicon 上 systemsetup 需要管理员授权才可执行;显示器熄屏时间由 pmset displaysleep 单独控制。
04撤销
撤销
$ sudo systemsetup -setcomputersleep 005来源
- systemsetup - Set System Configuration Preferences依据: Documents -setcomputersleep minutes (0 = never) and -getcomputersleep for reading the current idle-sleep timer.
- systemsetup(8) man page依据: The systemsetup man page describes -setcomputersleep as setting the system sleep amount in minutes and -getcomputersleep as displaying it.
最后验证: 2026-09-19 · 分类: 系统与设置