Murphy Mac - Screencasts and Tutorials » Page 'Reboot or Sleep a Mac from your iPhone'

Reboot or Sleep a Mac from your iPhone

Share

Sometimes Murphy is just a little too lazy to go upstairs and reboot a Mac that needs rebooting. With an iPhone or iPod touch you don’t need to leave the sofa.

Today, Murphy was watching tv on the iPhone via EyeTV’s iPhone app. It started to lock up so a reboot seemed like a good idea. Murphy has Touch Term installed on the iPhone. And the Mac is set to accept SSH sessions. One tap to connect and one command to start the reboot was all it took. Here’s what you need:

  • First, go to Sharing in your System Preferences. Turn on Remote Login. This allows your Mac to allow incoming SSH sessions.
  • On your iPhone install Touch Term, or some other SSH client. Murphy remembers getting Touch Term for free, but now it starts at $3.99. You might want to comparison shop for similar products.
  • Next, configure Touch Term to connect to your Mac, either by name or ip address.
  • Once you’ve connected just type the command to reboot your Mac, and press Return. Here’s the command:    sudo shutdown -r now

Murphy took the extra step of creating a shell script to run that command, so there’s less to type when it’s time to reboot.  That’s all there is to it.

You might want a command to send your Mac to sleep instead of rebooting it.  This command should accomplish that:   osascript -e 'tell application "System Events" to sleep'

Of course, you can always try something completely different.  A long time ago Murphy wrote some posts about using the Mail app on a Mac to trigger events.  Murphy has Applescripts on the Mac that do different things when emails come in with certain characteristics.  Scripts that adjust iTunes, retrieve files, or put the Mac to sleep.  The whole thing was based on a post here.

Some of these scripts had issues with different updates to OS X and changes to Mail.  Your results may vary…

I haven’t looked into other ways to reboot my Mac from the iPhone, so if you’ve got a good way let me know.

As always, be careful when using the Terminal.

| Permalink

Leave a comment