Auto-sync: 2026-04-17 08:37

This commit is contained in:
2026-04-17 08:38:12 +08:00
parent 6caa1c2f47
commit a0a48bd334
247 changed files with 6577 additions and 3061 deletions

View File

@@ -0,0 +1,52 @@
---
title: "caffeinate"
type: concept
tags: [macos, power-management, command-line]
date: 2026-04-17
---
## Definition
caffeinate 是 macOS 内置工具,用于临时阻止系统进入睡眠状态。与 pmset 不同caffeinate 不修改系统设置,仅在运行时有效,按 Ctrl+C 停止后系统恢复默认睡眠行为。
## Installation
```bash
# macOS 内置,无需安装
```
## Usage
```bash
# 防止显示器睡眠
caffeinate -d
# 防止系统空闲时睡眠
caffeinate -i
# 防止系统睡眠
caffeinate -s
# 模拟用户活动(防止睡眠)
caffeinate -u
# 组合使用(常用)
caffeinate -d -i -s
# 保持唤醒(按 Ctrl+C 停止)
caffeinate -d -i -s
```
## Parameters
| 参数 | 作用 |
|------|------|
| `-d` | 防止显示器睡眠 |
| `-i` | 防止系统空闲时睡眠 |
| `-s` | 防止系统睡眠 |
| `-u` | 模拟用户活动(防止睡眠) |
## Use Cases
- 临时运行需要持续运行的任务(如大型下载、安装)
- 演示或展示时需要保持屏幕常亮
- 不希望修改系统电源设置时的临时方案
## Related Concepts
- [[pmset]]:永久修改系统电源设置的工具
- [[WOL (Wake on LAN)]]:网络唤醒功能