Shared access to Mac OS X: how to manage wakeonlan and sleep

Ryan Schmidt ryandesign at macports.org
Mon Jul 6 18:22:05 PDT 2009


On Jul 6, 2009, at 17:47, Jean-Michel Pouré wrote:

> The Mac goes to sleep automatically after 3 hours of inactivity.

Then I assume you are either all on the same subnet as this Power Mac  
and can therefore send it a wakeonlan signal yourself, or else you  
have a device on the local subnet (perhaps a router running DD-WRT or  
another machine that's always on) to which you first connect and tell  
it to wake the Power Mac.


> My questions :
>
> * How can I manage sleep so that it is triggered after an SSH
> disconnection and let's say 30 minutes of inactivity.
>
> * When using screen, I would like to be sure that the Mac does not  
> go to
> sleep.

I don't know a built-in way to accomplish either of those, but I'm  
not familiar with what hooks might be available in the ssh or screen  
programs to let you do this.

Personally whenever I want to sleep my machines I use small script  
"sleepmac" I wrote which looks like this:


#!/bin/sh

if [ ! -z "$1" ]; then
         sleep $1
fi

SLEEPWATCHER=/opt/local/sbin/sleepwatcher

if [ -x $SLEEPWATCHER ]; then
         $SLEEPWATCHER --now
else
         osascript -e 'tell app "System Events" to sleep' &
fi


You can specify a delay before sleeping, e.g. to sleep in one minute:

sleepmac 60

It uses the sleepwatcher port if installed, or AppleScript if not.  
There was some set of circumstances that I cannot recall or test for  
at the moment whereby sleep wouldn't work, complaining instead of an  
inability to connect to the windowserver, and I believe it involved  
being logged in via ssh and/or using screen. I think using  
sleepwatcher instead of AppleScript may have helped with this, or at  
least I was testing whether this helped. I have primarily been using  
Tiger so I don't know if any of this has changed on Leopard.

sleepwatcher has many more capabilities that might be useful to you  
if you wanted to write a script or scripts to help you manage the  
requirements you mentioned.


> * Is sleep state safe?

It should be safe to put a machine to sleep in the middle of a  
compile, and it should resume where it left off when you wake up. If  
that's what you mean.


> I would like to know if some of you have innovating solutions. This is
> only a compilation platform. We also have VNC access to view the  
> result
> and verify that Kdenlive runs smoothly.




More information about the macports-dev mailing list