Run script on suspend/resume in Mac OS X

14

Is there any way to automatically run a script on suspend/resume (i.e. when I close the lid, or after opening it) under Mac OS X 10.4?

John Fouhy

Posted 2008-09-19T02:31:13.860

Reputation: 2 995

More current answers here: http://apple.stackexchange.com/questions/27036/possible-to-run-scripts-on-sleep-and-wake ....

– jcollum – 2012-11-10T20:54:59.300

Answers

3

Maybe try Sleepwatcher. Can't vouch for it, but found it after following Kevin's tips:

SleepWatcher 2.0.5 (now compatible with Mac OS X 10.5 “Leopard”) is a command line tool (daemon) for Mac OS X that monitors sleep, wakeup and idleness of a Mac. It can be used to execute a Unix command when the Mac or the display of the Mac goes to sleep mode or wakes up or after a given time without user interaction. It also can send the Mac to sleep mode or retrieve the time since last user activity.

rampion

Posted 2008-09-19T02:31:13.860

Reputation: 3 130

4

Depending on the problem you're trying to solve, launchd might work. It will run tasks that were scheduled while the machine is asleep when it wakes up. It's also smart enough to only run one instance of the task if several intervals have passed while the machine was asleep.

See Getting Started with launchd from Apple.

Otto

Posted 2008-09-19T02:31:13.860

Reputation: 241

1

I believe SleepWatcher can provide the functionality you are looking for.

DGentry

Posted 2008-09-19T02:31:13.860

Reputation:

rampion@ has already mentioned this – Rishi Dua – 2015-12-08T09:32:19.110