Running
caffeinate
is a great solution for my use case (need to keep the system up so that it can complete running a network backup utility) since unlike the pmset commands, it is fully reversible (all effects are undone when you Ctrl-C or close the terminal window and the
caffeinate
program exits, and it can even be run with a timeout of its own (output from
man caffeinate, edited for clarity):
SYNOPSIS
caffeinate [-dimsu] [-t timeout] [-w pid] [utility arguments...]
Available options:
-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. This ... is valid only when system is running on AC power.
-u Declare that user is active. If the display is off, this option turns the display on and prevents the
display from going into idle sleep. If a timeout is not specified with '-t' option,
then this [uses] a default of 5 second timeout.
-t Specifies the timeout value in seconds ... Timeout value is not used when a utility is invoked
with this command.
-w Waits for the process with the specified pid to exit. caffeinate exits when the process does.
This option is ignored when a utility command argument is given.
EXAMPLE
caffeinate -i make
caffeinate runs make and prevents idle sleep as long as that process is running.