View Full Version : run scripts at login/wake and sleep/shutdown

Sep 16, 2010, 07:46 AM
I have written two simple scripts (one line each) to do some copying (backing up) of files using rsync. It would be nice not to have to remember to do this manually every time. It seems to me that if I could get one of the scripts to run when I log in or the computer wakes up, and the other script runs when I shut down or the computer goes to sleep, that would be great. But I don't really have a clue how to do this. I looked into sleepwatcher, but I saw this in the man pages:

-s sleepcommand, --sleep sleepcommand
Execute sleepcommand when the Mac is put to sleep mode. sleepcommand must not take
longer than 15 seconds because after this timeout the sleep mode is forced by the sys-

I guess it's possible sometimes the copying of files would take more than 15 seconds, so this seems a no go.

Any suggestions?
Thanks in advance,

Sep 16, 2010, 07:50 AM
This is a page I've had booked marked for a while. It probably won't get you all the way there, but hopefully it will help you some.


Sep 16, 2010, 08:40 AM
thanks for that: i hadn't seen it. if i end up having to come up with, let's say, less streamlined solution i might use that to handle running the script on login.