Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to leave rsync working over wifi for hours turned on AC power. But when I do so the Mac breaks the connection after some time.

On Energy Settings pane it's configured to "Computer Never Sleep", "Put hard disk to sleep when possible" and "Wake for network access".

Plus it'd be good if the mac actually goes to sleep once the task is done.

I realize a very similar question have been asked before and that there is pmset and insomniaX, but I don't want the machine to be sleepless. And I don't want to keep installing more and more extensions, nor have to tweak through pmset every time.

I want it to natively behave as expected - stay awake while I leave it running a task, and then go to sleep "when possible". This time is due to rsync, but next time could be something else.

Am I expecting too much as usual? Can I fix it? Is it even broken?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

Jiggler can be set to only "jiggle" the mouse when it's running. This will prevent the screen and the computer from sleeping. This will not work on a laptop with the lid shut. For that you'd need InsomniaX or another kext based application.

enter image description here

share|improve this answer
    
No lid shut, that's fine. I don't want overheat. –  Cawas Feb 22 '10 at 15:52
    
Handy little application, indeed. –  ayaz Feb 22 '10 at 16:29
    
Well, while I don't need it again, this actually solved my problem, and it seems like a nice solution. I guess I should have accepted it way before. –  Cawas Mar 9 '10 at 1:16
add comment

Another alternative is Caffeine. It's an app - not an extension - which keeps the machine "active" for a specified period of time, after which the machine can do whatever it would normally do: go blank, run screensaver, sleep, etc. That is, it won't put your machine to sleep, but will let it. It seems functionally equivalent to setting the energy saver settings to "never" for the period you ask for, and restoring them afterward.

enter image description here

share|improve this answer
    
But you still have to start and stop the app. You can't set it and forget. –  Josh K Feb 23 '10 at 0:26
    
I'll give it a shot next time. Thanks! –  Cawas Feb 23 '10 at 19:35
add comment

You might consider making a Stay-Open Applescript Application that sets/resets the sleep timer based on the existence of a running process. Creating a launchd plist is also a viable solution, however I'm still shaky on the syntax. The "pmset force sleep X" command doesn't require root access, but the settings are reset on reboot.

Since your situation sounds like I won't be able to anticipate your every need, I'll sketch something out for you.

property LoopTime: 5 --measured in seconds
property normalSleepTimeout: 30 --measured in minutes
property processName: "rsync"  --the name of the process you're trying to find

on run
   do shell script "pmset force sleep 0"  --disables sleep
   idle()
end

on idle
   if not appIsRunning() then 
      do shell script ("pmset force sleep " & normalSleepTimeout as string) -- sets sleep to desired idle timeout
      quit
   end
   return 
end

on appIsRunning()
   --Here's where you need to do the test that an app is running.  True needs to mean "the app is running".  Store the value to "result" or change the below return statement.

   return result
end

For things like rsync and background processes, you'll need to get more clever and poll other functions like $ top.

set result to False
if 0 < (count of (do shell script ("top -l 1 | grep" & processName as string))) then
   set result to True
end

Notice that in the above case, searching for just "rsync" will return a false positive if rsyncd is running because both "rsync" and "rsyncd" match. You may have to get more tricky if this doesn't work for you.

If the application were a Windowed process, I'd use the following to determine what's running:

tell application "System Events" to set RunningAppNames to name of processes

Or for bundle identifiers (more precise)

tell application "System Events" to set RunningBundles to bundle identifier of processes

Tell me more about your scenario and I'll try to write something more exact and with a more flexible user interface.

share|improve this answer
    
dam, I'll look at all you said here another time, but thanks for going through all this trouble! I'm not really considering writing scripts for now, though. :) –  Cawas Feb 23 '10 at 19:34
    
Thanks for bringing my answer back up to a non-negative value. I live by scripting. I'm terrible with BASH, but I absolutely love AppleScript and running Terminal commands from it. –  Kio Dane Mar 1 '10 at 5:41
add comment

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.