Making a Mac wake and sleep remotely

Making a Mac wake and sleep remotely

I’ve been having a play with the sleep options on my new iMac over the last few days. Since it’s replacing an always-on PC, I could keep this always-on too, but I thought I may as well make it sleep overnight and save the planet from global warming.

As an aside, I don’t believe in global warming. But anyway.

Things weren’t working right, as far as sleeping was concerned, and I asked about in uk.comp.sys.mac for some help. An interesting idea was proposed for making my Mac sleep all the time, except when I need to use it – even if that was remotely. So how do I make it wake up and sleep from another location?

Sleep

Since I can SSH into it from the outside world, I had a look to see what command will put the machine to sleep from an SSH session. Thanks to this page (in the comments), I found the answer to be the following command:

osascript -e 'tell application "System Events" to sleep'

Easy!

Wake Up

Now, this is a bit more tricky. Of course, you can set the Energy Saver settings to “Wake for Ethernet network administrator access” – Wake On LAN, basically. Thing is, it’s behind a router on the other side of the internet, and my router isn’t fancy enough to support sending out Magic Packets.

Thankfully, uk.comp.sys.mac had an answer for this too, with this website. You just fill in your MAC address (that’s MAC not Mac!) router IP or full address, and what port you want to sent the Magic Packet on. Of course, you need to tell your router to forward that port to your Mac, but that’s simple enough. Click the button, and rise and shine!

All this was an interesting and enlightening diversion, but it doesn’t really solve my original problem of my iMac not going to sleep when it’s supposed to…

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.