caffeinate
Prevent your Mac from sleeping with the Caffeinate command. Learn how to keep your system awake indefinitely or for a specified duration. Free online tool.
Caffeinate Command
Prevent Mac Sleep with Caffeinate
The caffeinate
command is a powerful utility for macOS
users to prevent their system from entering sleep mode. This is
particularly useful for developers who need to run long processes,
downloads, or presentations without interruption. By default, macOS
has power-saving features that put the system to sleep after a
period of inactivity, but caffeinate
offers a way to
override this behavior.
How to Use Caffeinate
You can use caffeinate
in several ways, depending on
your needs. Here are some common examples:
Prevent Mac Sleep for a Specific Duration
To prevent your Mac from sleeping for a set amount of time, use the
-t
flag followed by the duration in seconds. For
instance, to keep your Mac awake for 1 hour (3600 seconds):
caffeinate -u -t 3600
The -u
flag asserts that the user is active, which is
often necessary for the timer to function correctly.
Prevent Mac Sleep Until a Command Completes
A very common and useful application of caffeinate
is
to keep the system awake while a specific command is running. This
ensures that long-running scripts or processes are not interrupted
by sleep mode. Use the -s
flag for this purpose:
caffeinate -s your_command_here
Replace your_command_here
with the actual command you
want to execute. The system will remain awake until
your_command_here
finishes.
Understanding Caffeinate Options
The caffeinate
command offers various options to
fine-tune its behavior. Some key flags include:
-d
: Prevent the display from sleeping.-i
: Prevent the system from idle sleeping.-m
: Prevent the disk from idle sleeping.-
-s
: Prevent the system from sleeping when plugged into AC power. -u
: Assert that the user is active.-t seconds
: Specify a timeout in seconds.