Schedule sleep and wake from the Terminal

Dec 18, 2009 - 5 Comments

terminal-icon-512x5122 Like many of us, I’ll be quite busy over the Christmas holiday visiting friends and relatives out of town. I regularly use my home machine as a local fileserver though and other people in the household are dependent on it being up and running. Now here’s the situation I’m presented with: I leave town earlier than my housemates do, but I don’t want to have to rely on someone who is not particularly computer savvy to put my Mac to sleep, so what do I do? Schedule it!

Being a bit on the geeky side, I’ll do this from the command line, which serves two purposes:
1) it’s geeky
2) it is exactly what you could do if you are currently away from your Mac but want to schedule sleep and wake remotely.

Here’s how you can schedule sleep and wake via the command line, remember you can do this remotely by SSH’ing into the Mac you want to schedule:
pmset schedule sleep "12/24/2009 00:00:00"
Now my system will go to sleep on Christmas Eve, the 24th of December.

pmset schedule wake "12/26/2009 00:00:00"
This command insures that my Mac wakes up the day after Christmas

That’s all there is to it! Now my Mac will sleep and wake on it’s own, independent of anyone else interfering with the machine. Note that you can do all of this through the Energy Saver GUI too but that’s not as fun (for me at least).

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Bill Ellis in Command Line, Mac OS X, Tips & Tricks

5 Comments

» Comments RSS Feed

  1. Carl says:

    Nice. Even faster than using the GUI. Are the scheduled event added through pmset reflected in the energy saver prefpanel? Also, is it possible to schedule reccuring events through pmset? (I know I could try it out or check the man page, but I feel lazy + It’s somewhat a good point of discussion)

    cheers.

  2. BitterMacFace says:

    @Carl, yes the pmset command changes are reflected in Energy Saver panel, you’ll notice that any setting made by pmset beyond the norm adjusts things within the preferences GUI to “Custom”

    pmset has a ton of other possibilities, like timing boots, shutdown, sleep, I am about 95% sure the Energy Saver GUI is just a front end to the pmset command itself.

  3. lostinasafari says:

    hi, i tried this, and its telling me “pmset: this operation must run as a root” is it because i have 10.6? :P

  4. Chip says:

    lost: no, you just need to run it with “sudo” in front of the “pmset….” it just wants to make sure you’re a system admin :)

  5. Andrew says:

    Hi,

    Nice tip.

    Before the computer goes to sleep it brings up a dialogue saying if nothing is done it will shut down in 10mins.

    Is there a way to remove this prompt? There’s nothing in the pref pane.

    Thanks again

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates