Command Line Power Management

Power Management is handled using the pmset command line utility, which I covered in a very small part yesterday.  There’s a lot more than just waking on magic packets that you can do with pmset though.  For starters, let’s look at the original command we discussed:

pmset -a womp 1

The -a refers to which power setting appled to whether the change was being made to battery, when we’re plugged in, UPS based power or, as we selected, all.  The flags, which fall into the first positional parameter are:

The next parameter you’ll pass to the command is the option (argument) for that power setting that you would like to send.  Here, you can set the number of minutes before the display goes to sleep, the brightness at various power settings and other options that have a direct effect on power.  These include the following (no – required with their use and 0 or 1 is boolean):

In addition to these, you can also use pmset to get information with the -g flag.  Using -g alone will net you all of the available information and while there are other options to limit what it outputs I normally just use grep for that…

There are also a number of options for managing SafeSleep (maintain the system state in memory, argument is hibernatemode), UPS options (haltvalue for how much battery to trigger a shutdown and halfafter for when to spin the CPU to 50% of full).  If you’re trying to manage the system and you have a battery (such as a laptop plugged into a UPS) then the settings will not be respected…

Just like in the System Preference pane, you can also control when the system sleeps, wakes, powers on, shuts down as well.  This uses the type argument (options being sleep, wake, poweron and shutdown) in conjunction with using date, time, weekdays and owner to set specific options.  

There are also a few other options that you don’t have in the GUI (’cause most of these are there).  These include force, which doesn’t write settings to disk, touch which reads currently enforced settings from the disk, noidle, which prevents idle sleep (and just spins the disk down when it’s ready) and  sleepnow, which just straight up puts the system to sleep right then.  sleepnow is pretty useful when you’re troubleshooting why a system won’t go to sleep.

For the Xserve specifically there is also a Lights Out Management in the form of the IPMI toolkit from Intel.  You can use that to power systems on, power them off and perform a few other tasks.  This can be secured (and actually has to be secured) with a password, using Server Monitor.  You can then control state through Server Monitor, or more granularly (and more importantly routable) through Apple Remote Desktop.  Find out more about IPMI on this page over at Intel.com.

Similar Articles:

Posted on March 17, 2009 at 3:33 am by admin · Permalink
In: Mac OS X, Mac OS X Server · Tagged with: , , ,

One Response

Subscribe to comments via RSS

  1. Written by Clint Howard
    on January 19, 2010 at 11:54 am
    Permalink

    I have a MacBook Pro and I am trying to prevent the harddrive from sleeping whilr allowing the display to sleep. I want to do this in order to remote control my iTunes with my iPhone Remote application and play music in remote location via AirPort Express. I did not notice any of the commands listed here to do that. Any help would be appreciated

Subscribe to comments via RSS

Leave a Reply