brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pmset -g log shows when your Mac slept and woke, and why

Terminal
~/tips/tip-macos-pmset-g-log-wake

pmset -g log | grep -i wake

Lists the recent sleep and wake events of your Mac to explain battery drain.

You close the lid of a MacBook in the evening and find a fuller battery drain in the morning than you expected. Before you blame an app, I’d look at what the Mac itself wrote down about the night.

pmset -g log prints a history of sleeps, wakes and other power management events. The man page calls it a log for admin and debugging purposes, which is a polite way of saying it is long. So filter it:

pmset -g log | grep -i wake

Each line starts with a date and time, followed by a short description of the event. Read the wake lines from the night in question and you can usually tell what got the Mac out of bed. Add | tail -n 40 to only see the latest entries. If you just want the numbers, there is a shorter command:

pmset -g stats

That prints how many times the system slept and woke since the last boot. A count far higher than the number of times you opened the lid is your hint to dig into the log.

This tip pairs well with pmset -g assertions, which I covered separately: assertions tell you what keeps the Mac awake right now, while the log tells you what happened earlier. On my MacBook Pro I’d reach for the log first when the question starts with “why did it”.

The caveat: the format of these lines is not documented as a stable interface, and it can change between macOS versions. Grep loosely, read the lines yourself, and don’t build a script that depends on the exact wording.

Further reading: pmset man page (ss64), pmset.1 source (Apple open source)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link