Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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:

  1. The terminal window is closed,
  2. Break (control+c) is entered,
  3. uTorrent is closed,
  4. Until restart or log out, or
  5. 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?

share|improve this question
    
Strange that you'd need that. Transmission for example seems to keep my iMac awake for as long as there are active transfers. –  Gerry Aug 23 '12 at 20:52

1 Answer 1

up vote 1 down vote accepted

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 && caffeinate -t 60

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

share|improve this answer
    
when I run caffeinate -i & open -W -a uTorrent.app I see this in terminal: James-RMBP:~ james$ caffeinate -i & open -W -a uTorrent.app [1] 1938 -- sorry I don't really understand formatting in this comment section. But basically it appears that its not really running in the background because the cursor doesn't return and if I close the shell, caffeinate is terminated when I run pmset -g assertions did you mean to just run caffeinate -i &? as a total system don't sleep? in that case it would be easier to set sleep to never. I was looking for a one time white list so to speak –  g3nius Aug 23 '12 at 22:38
    
Add the ampersand to the end: caffeinate open -W -a uTorrent &. –  Lri Aug 23 '12 at 23:15
    
the caffeinate open -W -a uTorrent & seems to work. My issue now is that I have to remember to leave the terminal window up... I wish the program Caffeine with its easy interface would be updated to work with 10.8 or uTorrent would make its power assertions compatible with mountain lion. Thanks for the help! –  g3nius Aug 26 '12 at 19:53
    
If you open caffeinate on the background, you can close the shell window. Just terminate caffeinate processes with killall caffeinate later. –  Lri Aug 26 '12 at 19:59
    
I must be doing something wrong because when I run caffeinate open -W -a uTorrent & it will show PreventUserIdleSystemSleep 1 but when I go to close the shell window I am asked "Do you want to close the window...closing the window will terminate the running processes: caffeinate, open." If I hit close, then reopen a new shell window and run pmset -g assertions it shows PreventUserIdleSystemSleep 0 What am I missing? –  g3nius Aug 27 '12 at 0:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.