sudo pmset -a disablesleep 1 · Chris Parmer
TIL:
$ sudo pmset -a disablesleep 1
Keeps your MacBook running even when you close the screen. So you can keep<br>that process running while you migrate from the coffee shop to the office.<br>Or the office to the airport.
Embarrased to say the number of times I've kept the lid of my computer<br>precariously cracked open in my backpack over the years.
Seemingly undocumented. I had heard about $ caffeinate -dimsu<br>but that doesn't seem to work anymore, even though it's man page looks<br>promising:
$ man caffeinate
SYNOPSIS<br>caffeinate [-disu] [-t timeout] [-w pid] [utility arguments...]
DESCRIPTION<br>caffeinate creates assertions to alter system sleep behavior. If no assertion flags are specified, caffeinate creates an assertion to<br>prevent idle sleep. If a utility is specified, caffeinate creates the assertions on the utility's behalf, and those assertions will<br>persist for the duration of the utility's execution. Otherwise, caffeinate creates the assertions directly, and those assertions will<br>persist until caffeinate exits.
Available options:
-d Create an assertion to prevent the display from sleeping.
-i Create an assertion to prevent the system from idle sleeping.
-m Create an assertion to prevent the disk from idle sleeping.
-s Create an assertion to prevent the system from sleeping. This assertion is valid only when system is running on AC power.
-u Create an assertion to declare that user is active. If the display is off, this option turns the display on and prevents the<br>display from going into idle sleep. If a timeout is not specified with '-t' option, then this assertion is taken with a default<br>of 5 second timeout.
-t Specifies the timeout value in seconds for which this assertion has to be valid. The assertion is dropped after the specified<br>timeout. Timeout value is not used when an utility is invoked with this command.
-w Waits for the process with the specified pid to exit. Once the the process exits, the assertion is also released. This option<br>is ignored when used with utility option.
EXAMPLE<br>caffeinate -i make<br>caffeinate forks a process, execs "make" in it, and holds an assertion that prevents idle sleep as long as that process is running.
SEE ALSO<br>pmset(1)
LOCATION<br>/usr/bin/caffeinate
Darwin November 9, 2012 Darwin
Of course, don't forget to turn the flag back off so your computer can sleep again.
$ sudo pmset -a disablesleep 0
Thanks Isaac for the tip.