Linux command
caffeinate 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Prevent idle sleep
caffeinate
Prevent the display from sleeping
caffeinate -d
Prevent idle sleep for a duration
caffeinate -t [3600]
Prevent sleep while a command runs
caffeinate -i [make]
Combine flags
caffeinate -dim -t [3600]
Hold the assertion until a process
caffeinate -w [pid]
Prevent system sleep
caffeinate -s
说明
caffeinate creates one or more IOKit power-management assertions to suppress different kinds of sleep. It is the supported way to prevent macOS from entering display, idle, disk, or system sleep for the duration of a task. When invoked with a utility, caffeinate forks and runs the utility with the assertion(s) held until the utility exits. Without a utility, it runs until it receives a signal (e.g. Ctrl-C) or until `-t` expires. Multiple flags may be combined; each adds its own assertion.
参数
- -d
- Prevent the display from sleeping.
- -i
- Prevent the system from idle sleeping. (default when no assertion flag is given)
- -m
- Prevent the disk from idle sleeping.
- -s
- Prevent the system from sleeping. Only effective when plugged into AC power on a laptop.
- -u
- Declare that the user is active. The assertion is released automatically after 5 seconds (or sooner if cancelled) — useful to bump activity without holding it indefinitely.
- -t _timeout_
- Release the assertion after _timeout_ seconds. Without this flag the assertion holds until caffeinate is terminated or the wrapped utility exits.
- -w _pid_
- Hold the assertion until the process with the given PID exits.
FAQ
What is the caffeinate command used for?
caffeinate creates one or more IOKit power-management assertions to suppress different kinds of sleep. It is the supported way to prevent macOS from entering display, idle, disk, or system sleep for the duration of a task. When invoked with a utility, caffeinate forks and runs the utility with the assertion(s) held until the utility exits. Without a utility, it runs until it receives a signal (e.g. Ctrl-C) or until `-t` expires. Multiple flags may be combined; each adds its own assertion.
How do I run a basic caffeinate example?
Run `caffeinate` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -d do in caffeinate?
Prevent the display from sleeping.