How to Use the macOS pmset Command to Optimize Battery and Sleep Settings

The Black Box of Mac Power Management

macOS is renowned for its exceptional laptop battery life and seamless transition in and out of sleep states. For standard users, the graphical “Energy Saver” or “Battery” pane in System Settings provides a few basic sliders (like turning the display off after 5 minutes).

However, for system administrators managing fleets of MacBooks, or developers utilizing a Mac Mini as a headless continuous integration (CI) server, the graphical settings are vastly insufficient. You cannot use the graphical interface to configure a Mac to automatically boot up every weekday at 6:00 AM, nor can you precisely configure the deeply hidden “Standby” hibernation timers that dictate exactly when a MacBook writes its RAM to the SSD to conserve the last 5% of battery.

To control the macOS power management subsystem (handled by the SMC – System Management Controller), administrators must use the pmset (Power Management Settings) command.

Step 1: Viewing the Current Power State

Before modifying any settings, you should view the current configuration.

Open the Terminal and run:

pmset -g

This command dumps the active power profile. You will see a list of obscure variables, such as hibernatemode, tcpkeepalive, ttyskeepawake, and displaysleep.

Crucially, pmset maintains distinct profiles depending on the current power source. If you run pmset -g custom, you will see separate configuration blocks for Battery Power and AC Power. Modifying settings carefully allows you to maximize performance while plugged in, but ruthlessly aggressively conserve energy when on battery.

Step 2: Understanding Sleep vs. Hibernation (hibernatemode)

When you close the lid of a MacBook, it does not actually turn off. By default, it enters a state determined by the hibernatemode variable.

  • hibernatemode 0 (Standard Sleep): The Mac keeps the RAM powered on. Waking up is instantaneous, but it drains battery continuously. (Default on desktop Macs).
  • hibernatemode 3 (Safe Sleep): The Mac keeps RAM powered on for fast wake, but simultaneously writes a copy of the RAM to the SSD (the sleepimage). If the battery completely dies during the night, the Mac restores from the SSD. (Default on MacBooks).
  • hibernatemode 25 (True Hibernation): The Mac dumps RAM to the SSD and completely kills power to the memory. Waking up takes significantly longer, but battery drain is virtually zero.

If you are traveling for a week and want maximum battery preservation, you can force your MacBook into true hibernation mode:

sudo pmset -a hibernatemode 25

(The -a flag applies the setting to All power sources. You can use -b for Battery only, or -c for Charger only).

Step 3: Disabling Power Nap and Network Wakeups

A common complaint among MacBook users is pulling the laptop out of a backpack only to find it extremely hot with a drained battery. This is usually caused by “Power Nap” (TCP Keepalive and Wake on LAN), which wakes the Mac in the background to check emails and sync iCloud data while asleep.

To ruthlessly disable all background network wakeups while on battery power:

sudo pmset -b tcpkeepalive 0
sudo pmset -b powernap 0

Note: Disabling tcpkeepalive will break Find My Mac when the laptop is asleep, as it can no longer beacon its location to Apple’s servers.

Step 4: Scheduling Automated Power Events

If you manage a lab of iMacs or a Mac Mini server, you can use pmset to enforce strict operational hours, ensuring machines are turned off at night to save electricity, but booted up and ready before employees arrive.

The scheduling syntax uses MTWRFSU for days of the week.

To configure the Mac to automatically wake up (or boot up if fully powered off) every Monday through Friday at 7:00 AM:

sudo pmset repeat wakeorpoweron MTWRF 07:00:00

To verify the active schedule, run:

pmset -g sched

If you want to clear the schedule and stop the automated boot sequence, you simply cancel the repeat:

sudo pmset repeat cancel

Step 5: Preventing Sleep for Remote Servers (Headless Mode)

If you are using a Mac Mini as a remote server, it is infuriating if the machine goes to sleep simply because no physical monitor is attached. The Mac will drop your SSH connection.

You can use pmset to completely disable system sleep when plugged into AC power (the charger):

sudo pmset -c sleep 0

Additionally, you must ensure that if a user establishes an SSH session, the active terminal session prevents the Mac from sleeping during a long-running compile or backup job:

sudo pmset -a ttyskeepawake 1

Conclusion

The graphical Battery settings in macOS are heavily sanitized to prevent average users from making mistakes. By utilizing the pmset command, developers and system administrators can strip away those guardrails, explicitly controlling the hibernation algorithms, silencing background network noise, and enforcing rigid power schedules to optimize Apple hardware for strict enterprise workloads.

RELATED POSTS

  • How to Delete a Wi-Fi Network on a Mac
  • How to Lock Your Mac Screen
  • How to Export Apple Notes to PDF on Mac and iPhone
  • How to Use the Mac App Switcher to Quickly Change Programs
  • How to Enable the Hidden Built-in Trackpad Gestures on a MacBook
  • Get the best tech tips delivered straight to your inbox.

    Join thousands of readers mastering Apple, Google, Microsoft, and Linux.