Did my Mac sleep with the lid closed? How to check
Your long run stopped while the MacBook was closed, and you don’t know if the Mac slept or the job failed. macOS keeps a diary of every sleep and wake, with the reason. Three commands read it.
Short answer. pmset -g log | grep -E "Entering Sleep|Wake from" | tail -n 20 shows the last sleeps and wakes with times and reasons. pmset -g assertions shows what is keeping the Mac awake now. pmset -g | grep SleepDisabled tells you if sleep was switched off by hand.
1. When and why it slept
pmset -g log | grep -E "Entering Sleep|Wake from" | tail -n 20
Each line has a time, an event and a reason. A real example from the developer’s Mac:
2026-11-15 09:57:41 +0100 Sleep Entering Sleep state due to 'Maintenance Sleep' … Using Batt (Charge:77%) 1011 secs
2026-11-15 10:39:01 +0100 Wake Wake from Deep Idle [CDNVA] : due to … UserActivity …
What to look for:
- The reason in quotes.
'Clamshell Sleep'means the lid closed and nothing held the Mac awake.'Idle Sleep'means nobody touched it for a while.'Maintenance Sleep'and'Sleep Service Back to Sleep'are macOS going back to sleep after waking briefly for background work. - The time. If the Mac slept at 14:03 and your agent’s last log line is 14:03, you have your answer.
- The charge at that moment, and how many seconds it stayed asleep.
- DarkWake lines: brief wake-ups without the screen (Power Nap, maintenance). They don’t keep a job running.
The log only goes back a few days, so check soon after the run.
2. What keeps it awake right now
pmset -g assertions
This lists every app holding a power assertion: caffeinate, a video call, a download. It’s the quickest way to find out why a Mac won’t sleep. Remember that these assertions hold off idle sleep, not lid sleep (why caffeinate doesn’t work with the lid closed).
3. Was sleep switched off by hand?
pmset -g | grep SleepDisabled
1 means someone, or some tool, ran pmset disablesleep 1, and the Mac won’t sleep at all until it’s undone. 0 or no line means normal. How to undo it, and how to stop it coming back: pmset disablesleep explained.
A quick test before you trust any setup
- Start your keep-awake method (whichever you use).
- Note the time, close the lid for ten minutes, on battery.
- Open it and run the first command. No
Entering Sleepline in those ten minutes means it held.
Hibernot does this bookkeeping for you: when you open the lid, its panel says at what time and why the Mac went back to normal (time up, Claude finished, battery temperature, charge). The options for keeping a MacBook awake are compared in how to keep a MacBook awake with the lid closed.