Mountain Lion sleep and caffeinate command I am having an issue where my retina MacBook Pro (10.8.1) will sleep when uTorrent is actively uploading or downloading. I have tried my old go to programs like "Caffeine" and "InsomniaX" to no avail. I was about to try Jiggler, but when I am finished working at the machine for the night, I like to sleep the display (using a hot corner) and I want my display to remain off/asleep. Jiggler would wake the display every 5 minutes with the password prompt, then the display would sleep and this would repeat till the morning.  

I have read this question and the best answer was helpful but left me wanting to know more.

I am wondering if someone can give me a little more info on how the caffeinate command works?  For example, if I were to run the command caffeinate -i open -W -a uTorrent.app (which I assume is working because it will open uTorrent) does the caffeinate command remain active until:


The terminal window is closed,
Break (control+c) is entered,
uTorrent is closed,
Until restart or log out, or
Until a 'decaffeinate' or (complimenting command) is entered in the Terminal.


Basically if I wished to run the caffeinate command, would I have to run it every time I launched uTorrent?
The assertions are removed when the caffeinate process exits.


  caffeinate creates assertions to alter system sleep behavior.  If no assertion flags
  are specified, caffeinate creates an assertion to prevent idle sleep.  If a utility
  is specified, caffeinate creates the assertions on the utility's behalf, and those
  assertions will persist for the duration of the utility's execution. Otherwise,
  caffeinate creates the assertions directly, and those assertions will persist until
  caffeinate exits.


caffeinate (or caffeinate -i) prevents idle sleep until the process is terminated by for example pressing control-C or closing a shell window. caffeinate open -Wa uTorrent would also remove the assertion when open exits.

You can get a list of power assertions with pmset -g assertions. caffeinate or caffeinate -i should set PreventUserIdleSystemSleep to 1.



To always prevent sleep when uTorrent is open, you could add a line like this to a crontab:

* * * * * pgrep -x uTorrent &amp;&amp; caffeinate -t 60


(Use EDITOR=nano crontab -e if you haven't changed $EDITOR and don't know how to use vi.)