Results 1 to 7 of 7
  1. #1
    Any way to put OS X to sleep via Terminal?

    Member Since
    Apr 15, 2007
    Posts
    262
    Any way to put OS X to sleep via Terminal?
    Just wondering if it's possible to put the machine to sleep via a shell command.

  2. #2
    Any way to put OS X to sleep via Terminal?
    giulio's Avatar
    Member Since
    Mar 19, 2007
    Location
    NY USA
    Posts
    1,813
    Specs:
    iMac 5.1 | iMac 7.1 | iPod Touch | iPod Nano
    You need a shell script:

    #!/bin/bash
    osascript << EOT
    tell application "System Events"
    sleep
    end
    EOT
    It's not a one-liner.
    schweb This has to be one of the best threads ever in MF history...
    Cherokee This gets my vote for most innovative thread on Mac-Forums... ever.

  3. #3
    Any way to put OS X to sleep via Terminal?

    Member Since
    Apr 15, 2007
    Posts
    262
    Very cool. thanks!

  4. #4
    Any way to put OS X to sleep via Terminal?

    Member Since
    Apr 03, 2013
    Posts
    2
    Use 'pmset' -- Do a 'man pmset' for full options...

    So, to put your system to sleep via CLI, in terminal:

    -$ pmset sleepnow
    This is more straight forward than mucking about with osascript (though I do enjoy discovering more and more and more osascript trickery!).

  5. #5
    Any way to put OS X to sleep via Terminal?
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,392
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    You're about 8 years late to the conversation.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  6. #6
    Any way to put OS X to sleep via Terminal?

    Member Since
    Apr 03, 2013
    Posts
    2
    Yea, I hope that is OK -- I don't usually have the opportunity to help, and I realized I could answer this one for "somebody, sometime, hopefully"...

    All best to all...

  7. #7
    Any way to put OS X to sleep via Terminal?
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,392
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    Oh, that's not a problem at all. I just wanted to point that out in case you were hoping that the original poster would find your answer.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. never put iMac to sleep
    By nickyr in forum OS X - Operating System
    Replies: 12
    Last Post: 02-03-2015, 12:43 PM
  2. Can't put Macs to sleep while wi-fi is on
    By Straitsfan in forum OS X - Operating System
    Replies: 1
    Last Post: 12-04-2014, 04:49 PM
  3. so i put my computer to sleep...
    By y0itzr0 in forum Apple Notebooks
    Replies: 4
    Last Post: 04-05-2008, 02:43 AM
  4. It shuts down when I put it to sleep!
    By Hulk Hogan in forum Apple Desktops
    Replies: 7
    Last Post: 01-23-2007, 12:33 PM
  5. How often should i put my iMac to sleep?
    By SexyHolly in forum Switcher Hangout
    Replies: 18
    Last Post: 03-21-2005, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •