Pmset

Last updated

On Apple computers, pmset is a command line utility to manipulate power management settings under the Darwin and macOS operating systems. It can assign sleep settings, schedule sleep and wake times, and display power information.

Contents

History

The pmset utility first appeared in Darwin 6.0.1 and Mac OS X 10.2 "Jaguar". It has been updated periodically since its introduction, and is still available as of Darwin 21.2.0 and macOS Monterey.

Behavior

The utility sets or lists power management settings. Some of the functionality provided by the utility is available through the GUI interface of the Energy Saver preference pane. However, pmset allows for greater flexibility and access to several options not available in the GUI.

The utility can set different power management settings depending on usage scenario. Different settings can be applied for when the machine is running off a charger, battery, UPS, or all three. The appropriate flags are as follows:

Additional arguments be supplied when assigning any power management settings. Power management arguments are discussed in greater detail below. When invoking the command, only specified arguments modify power management options. Any arguments already set will be unmodified by pmset unless those arguments are specifically included.

The utility can schedule wake, sleep, power on or power off events. Events can be recurring based on arbitrary weekday and time combinations, or scheduled for future dates and times. The syntax for scheduling an event is as follows:

pmset [repeat, schedule] [sleep, wake, poweron, shutdown, wakeorpoweron] [<MTWRFSU> <date/time>]

Previously stored events will be overwritten upon running this command. To schedule multiple events they must be entered in one command string. For example, to set a shutdown event every day of the week at 23:59 and a wake or power on event every day of the week at 7:00 enter the following:

sudo pmset repeat shutdown MTWRFSU 23:59:00 wakeorpoweron MTWRFSU 7:00:00

The get flag displays information about the current power management configuration, or a log of recent activity. If no additional arguments are supplied the flag will only display current settings. Additional get arguments are discussed in greater detail below. The get flag is as follows:

To view the currently scheduled events type:

pmset -g sched

The utility is also able to configure hibernation and safe sleep options, and change Energy Saver profiles.

Power management settings

The pmset utility recognizes the following arguments. Arguments can be passed in serial form in any order. Any bad syntax or unrecognized argument will cause the entire command to fail, resulting in an error message and brief help screen. Power management settings can only be changed by a privileged user.

Settings may be adjusted independently for circumstances where the machine is attached to a charger, when running off a battery (in the case of a laptop), or when running off a UPS (if available). Settings can also be adjusted for all four scenarios simultaneously; this is the default option, for when no usage flag is specified. Power management options can be specified for different profiles by appending -c (charger), -b (battery), -u (UPS) or -a (all) flags. The following example will set the machine to sleep after 10 minutes and sleep the display after five minutes, but only when powered by the battery.

pmset -b sleep 10 displaysleep 5

The following command will assign slightly different power management settings for circumstances where the machine is powered by the charger. Here, the machine is set to sleep after 30 minutes and the display is set to never sleep, but only when set by the charger. Issuing both commands will not interfere with each other.

pmset -c sleep 30 displaysleep 0

Arguments can be entered in serial form to set or modify several power management parameters with one command. The following command will set the machine to never sleep (sleep 0), enable the Sudden Motion Sensor (sms 1), set the display to sleep after 20 minutes (displaysleep 20), disable processor speed reduction (reduce 0), enable intermediate display dimness (halfdim 1), enable the machine to wake when the lid is opened (lidwake 1), prevent the system from sleeping when a tty session (such as SSH) is active (ttyskeepawake 1), disable waking the machine when the AC adapter is inserted (acwake 0), disable an automatic restart after power is removed and restored (autorestart 0), enable dynamic change of processor speed based on system load (dps 1), enable wake on modem ring (ring 1), enable wake on receipt of "magic" Ethernet packet (womp 1), and disable hard disk sleep (disksleep 0):

pmset sleep 0 sms 1 displaysleep 20 reduce 0 halfdim 1 lidwake 1 ttyskeepawake 1 acwake 0 autorestart 0 dps 1 ring 1 womp 1 disksleep 0

Because the above example did not include a usage flag, the settings specified will apply to all usage scenarios. Subsequent commands that do specify a usage flag will only affect settings for that usage scenario. For instance, pmset -b sleep 10 will cause the machine to sleep after 10 minutes, but only when the battery is attached. All other settings will apply when the battery is attached, and all settings in the above example will apply when a charger or UPS is attached.

At least as of Darwin 9.4 and OS X 10.5.4 "Leopard", all changes made through pmset are saved in a persistent preferences file at /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist. This file can be modified manually using the defaults command, but those changes will not be taken up immediately by the power management system. Manual edits of com.apple.PowerManagement.plist also stand the risk of being overwritten. The command pmset touch will reread existing settings from disk and apply them to the system.

With autopoweroff enabled the machine will got into hibernate mode even if hibernatemode is 0. The value of autopoweroffdelay may be in seconds despite the man page (for Mavericks, Nov 9, 2012) documenting it as minutes.

Schedule Settings

The pmset command is able to schedule system sleep, shutdown, wakeup or power on events. The schedule argument is for setting up one-time power events, and repeat is for setting up daily or weekly events. Scheduling of events can only be done by a privileged user.

The schedule argument recognizes the following additional arguments:

The utility can be very unforgiving of improper syntax. Any errors in syntax will cause the command to fail and will display a brief help message. The syntax for a scheduled event is as follows:

pmset schedule [sleep, wake, poweron, shutdown, wakeorpoweron] "MM/dd/yy HH:mm:ss"

Only one type of event (sleep, wake, et cetera) can be specified, and the date chosen must be in the future. The utility expects to be able to store this information in the PMU, and so may not work reliably on non-Apple hardware. The date and time string must be enclosed in quotation marks.

The syntax for a repeating event is as follows:

pmset repeat [sleep, wake, poweron, shutdown, wakeorpoweron] [MTWRFSU, weekdays, weekends, everyday] HH:mm:ss

Scheduled wake, sleep and power events are stored in a persistent preferences file in /Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist. This file can be manually edited using the defaults command, but any changes so made stand a serious risk of being overwritten. Also, such edits will not be immediately taken up by the system.

List options

The list flag, -g, displays information about the current power configuration. The flag alone, with no additional arguments, will display current power management settings. Additional arguments will display more specific information. The get functions of pmset do not require privileged access. The utility recognizes the following arguments (an up-to-date list can be retrieved with the undocumented pmset -g getters command, though it does not show all *log variants):

Only one get argument can be passed to pmset -g. For instance, to display scheduled events, type pmset -g sched. The utility will not return an error if more than one get argument is provided, but all other than the first will be ignored.

The sleep and displaysleep can show an imposed value of 0 (disabled) together with a list of process IDs that impose this value. These are processes such as backup programs which need the machine to stay awake, for example until the backup is finished.

Sample usage

The following examples demonstrate the output of the pmset command on an Apple PowerBook G4 running Mac OS X 10.5.4 "Leopard".

The following example will put the relevant computer to sleep immediately:

pmset sleepnow 

The following example will apply only to laptops when powered by the battery. It will set the machine to sleep after 5 minutes of inactivity, put the display to sleep after 2 minutes, and spin down the hard disk after 3 minutes. Only privileged users can issue this command. If the command is issued successfully and is without syntax errors, pmset will exit silently with an exit code of 0. To verify that the system took the new configuration, issue the command pmset -g.

pmset -b sleep 5 displaysleep 2 disksleep 3 

The following example will apply only to machines being powered by a UPS. It will set the machine to perform an emergency shutdown when 5 percent battery remains on the UPS, or 5 minutes estimated draw time remains, whichever comes first. Only privileged users can issue this command. If the command is issued successfully and is without syntax errors, pmset will exit silently with an exit code of 0. To verify that the system took the new configuration, issue the command pmset -g.

pmset -u haltlevel 5 haltremain 5 

The following example will apply for all usage scenarios. It will set the machine to wake on receipt of a "magic" Ethernet packet, wake if the modem detects a ring, and prevent the system from sleeping if a tty session is active. Only privileged users can issue this command. If the command is issued successfully and is without syntax errors, pmset will exit silently with an exit code of 0. To verify that the system took the new configuration, issue the command pmset -g.

pmset -a womp 1 ring 1 ttyskeepawake 1 

The following example sets a one-time scheduled power event. The machine will be set to shut down 01/10/2009 at 10:00 PM (10 January 2009 – Note the US centric MM/DD/YYY time syntax). Only privileged users can issue this command. If the command is issued successfully and is without syntax errors, pmset will exit silently with an exit code of 0. To verify that the system took the new configuration, issue the command pmset -g sched.

pmset schedule shutdown "01/10/2009 22:00:00" 

The following example sets a repeating power event. The machine will wake or power on every weekday at 8:00 AM. Only privileged users can issue this command. If the command is issued successfully and is without syntax errors, pmset will exit silently with an exit code of 0. To verify that the system took the new configuration, issue the command pmset -g sched.

pmset repeat wakeorpoweron MTWRF 08:00:00 

Here, example output from pmset -g. At the time, the machine was being powered by the charger, while simultaneously charging the battery. The command prints the current configuration.

$ pmset -g Active Profiles: Battery Power  -1 AC Power  -1* Currently in use:  sleep  0  sms  1  displaysleep 20  reduce  0  halfdim 1  lidwake 1  ttyskeepawake 1  acwake  0  autorestart 0  dps  1  ring  1  womp  1  disksleep 0 

Here, example output from pmset -g sched. In this example, the machine has already been configured for a repeating event to start or wake up every weekday at 8:00 AM. The command prints the repeating event; note that the next such occurrence appears as a scheduled power event.

$ pmset -g sched Repeating power events:   wakepoweron at 8:00AM weekdays only Scheduled power events:  [0]  wakeorpoweron at 08/04/08 08:00:00 by Repeating 

Here, example output from pmset -g. At the time, the machine was being backed up. The output shows the PID for the backup program.

$ pmset -g | grep sleep  disksleep 10  sleep  0 (imposed by 33927)  displaysleep 5 $ ps -ef | grep 33927     0 33927     1   0  9:22am ??        10:54.97 /System/Library/CoreServices/backupd 

See also

Related Research Articles

<span class="mw-page-title-main">Wake-on-LAN</span> Mechanism to wake up computers via a network

Wake-on-LAN is an Ethernet or Token Ring computer networking standard that allows a computer to be turned on or awakened by a network message.

Power management is a feature of some electrical appliances, especially copiers, computers, computer CPUs, computer GPUs and computer peripherals such as monitors and printers, that turns off the power or switches the system to a low-power state when inactive. In computing this is known as PC power management and is built around a standard called ACPI, this supersedes APM. All recent computers have ACPI support.

Uptime is a measure of system reliability, expressed as the percentage of time a machine, typically a computer, has been working and available. Uptime is the opposite of downtime.

NTLDR is the boot loader for all releases of Windows NT operating system from 1993 with the release of Windows NT 3.1 up until Windows XP and Windows Server 2003. From Windows Vista onwards it was replaced by the BOOTMGR bootloader. NTLDR is typically run from the primary storage device, but it can also run from portable storage devices such as a CD-ROM, USB flash drive, or floppy disk. NTLDR can also load a non NT-based operating system given the appropriate boot sector in a file.

In computing, umask is a command that determines the settings of a mask that controls how file permissions are set for newly created files. It may also affect how the file permissions are changed explicitly. umask is also a function that sets the mask, or it may refer to the mask itself, which is formally known as the file mode creation mask. The mask is a grouping of bits, each of which restricts how its corresponding permission is set for newly created files. The bits in the mask may be changed by invoking the umask command.

<span class="mw-page-title-main">Sleep mode</span> Low power mode for electronic devices

Sleep mode is a low power mode for electronic devices such as computers, televisions, and remote controlled devices. These modes save significantly on electrical consumption compared to leaving a device fully on and, upon resume, allow the user to avoid having to reissue instructions or to wait for a machine to reboot. Many devices signify this power mode with a pulsed or red colored LED power light.

Hibernation in computing is powering down a computer while retaining its state. When hibernation begins, the computer saves the contents of its random access memory (RAM) to a hard disk or other non-volatile storage. When the computer is turned on the RAM is restored and the computer is exactly as it was before entering hibernation. Hibernation was first implemented in 1992 and patented by Compaq Computer Corporation in Houston, Texas. As of 2020, Microsoft's Windows 10 employs a type of hibernation by default when shutting down.

<span class="mw-page-title-main">H2 (DBMS)</span>

H2 is a relational database management system written in Java. It can be embedded in Java applications or run in client-server mode.

As the next version of Windows NT after Windows 2000, as well as the successor to Windows Me, Windows XP introduced many new features but it also removed some others.

Compared with previous versions of Microsoft Windows, features new to Windows Vista are very numerous, covering most aspects of the operating system, including additional management features, new aspects of security and safety, new I/O technologies, new networking features, and new technical features. Windows Vista also removed some others.

The Windows System Assessment Tool (WinSAT) is a module of Microsoft Windows Vista, Windows 7, Windows 8, Windows 10 and Windows 11 that is available in the Control Panel under Performance Information and Tools. It measures various performance characteristics and capabilities of the hardware it is running on and reports them as a Windows Experience Index (WEI) score. The WEI includes five subscores: processor, memory, 2D graphics, 3D graphics, and disk; the basescore is equal to the lowest of the subscores and is not an average of the subscores. WinSAT reports WEI scores on a scale from 1.0 to 5.9 for Windows Vista, 7.9 for Windows 7, and 9.9 for Windows 8, Windows 10 and Windows 11.

The booting process of Windows Vista and later versions differ from the startup process part of previous versions of Windows.

Windows Vista contains a range of new technologies and features that are intended to help network administrators and power users better manage their systems. Notable changes include a complete replacement of both the Windows Setup and the Windows startup processes, completely rewritten deployment mechanisms, new diagnostic and health monitoring tools such as random access memory diagnostic program, support for per-application Remote Desktop sessions, a completely new Task Scheduler, and a range of new Group Policy settings covering many of the features new to Windows Vista. Subsystem for UNIX Applications, which provides a POSIX-compatible environment is also introduced.

<span class="mw-page-title-main">Windows Task Scheduler</span> Computer application of Microsoft Windows

Task Scheduler is a job scheduler in Microsoft Windows that launches computer programs or scripts at pre-defined times or after specified time intervals. Microsoft introduced this component in the Microsoft Plus! for Windows 95 as System Agent. Its core component is an eponymous Windows service. The Windows Task Scheduler infrastructure is the basis for the Windows PowerShell scheduled jobs feature introduced with PowerShell v3.

Toybox is a free and open-source software implementation of over 200 Unix command line utilities such as ls, cp, and mv. The Toybox project was started in 2006, and became a 0BSD licensed BusyBox alternative. Toybox is used for most of Android's command line tools in all currently supported Android versions, and is also used to build Android on Linux and macOS. All of the tools are tested on Linux, and many of them also work on BSD and macOS.

powercfg is a command-line utility that is used from an elevated Windows Command Prompt to control all configurable power system settings, including hardware-specific configurations that are not configurable through the Control Panel, on a per-user basis. It was first introduced by Microsoft in Windows XP SP2 in 2004.

In computing, rebooting is the process by which a running computer system is restarted, either intentionally or unintentionally. Reboots can be either a cold reboot in which the power to the system is physically turned off and back on again ; or a warm reboot in which the system restarts while still powered up. The term restart is used to refer to a reboot when the operating system closes all programs and finalizes all pending input and output operations before initiating a soft reboot.

An Embedded Controller (EC) is a microcontroller in computers that handles various system tasks. Now it is usually merged with Super I/O, especially on mobile platforms.

References