title, type, tags, date
| title |
type |
tags |
date |
| caffeinate |
concept |
| macos |
| power-management |
| cli |
| server |
|
2026-03-15 |
Definition
caffeinate,macOS 内置工具,在指定命令执行期间临时阻止系统进入睡眠状态,不修改系统电源管理设置,执行完毕自动恢复睡眠行为。
Key Commands
| 命令 |
作用 |
caffeinate -d |
防止显示器睡眠 |
caffeinate -i |
防止系统空闲时睡眠 |
caffeinate -s |
防止系统睡眠 |
caffeinate -u |
模拟用户活动(防止睡眠) |
caffeinate -d -i -s |
全开,按 Ctrl+C 停止 |
Comparison with pmset
- pmset:永久修改系统电源管理设置,重启后保持
- caffeinate:临时防止睡眠,进程结束即恢复,适合一次性任务
Use Cases
- 执行备份、拷贝等长时间任务时临时防止睡眠
- 远程 SSH 会话中保持系统活跃
Related Concepts
- pmset:永久电源管理配置
- WOL:配合 caffeinate 使用,长时任务后远程唤醒
Source
Mac-Mini-服务器配置-防止自动锁屏与睡眠