I have a fleet of 7 macbook pro's running mac osx 10.10, 10.11, and 10.12, and 3 mac pro's running mac os 10.13 ("high sierra"). On all systems, I have set it to never sleep the system or display. Oddly, that doesn't suffice, so I also use caffeinate to prevent sleep. On the 10.13 systems, though, the display still goes to sleep, no matter what I try. This affects two things:

  • my opengl tests hang
  • "osascript -e 'tell app "System Events" to restart'" hangs

Since only the display is asleep, I can still ssh in and look around.

I currently run my script under caffeinate -dsiu -t 31536000, and when it hangs, evidently I've still got all the proper assertions going:

$ pmset -g assertionslog
2017-11-20 19:34:27 -0800 : Showing all currently held IOKit power assertions
Assertion status system-wide:
BackgroundTask 0
ApplePushServiceTask 0
UserIsActive 1
PreventUserIdleDisplaySleep 1
PreventSystemSleep 1
ExternalMedia 0
PreventUserIdleSystemSleep 1
NetworkClientActive 1

and yet the display is in DevicePowerState 1:

$ ioreg -n IODisplayWrangler | grep -i IOPowerManagement
| | "IOPowerManagement" = {"DevicePowerState"=1,"CapabilityFlags"=0,"CurrentPowerState"=1,"MaxPowerState"=4}

Executing another caffeinate -u wakes the display up and puts it into DevicePowerState 4 for 15 or so seconds, then it goes back to sleep and DevicePowerState 1, even if I give a longer timeout with -t. I've also tried repeating the -t argument after each assertion (in case the confusing manpage meant that).

To rescue "osascript -e 'tell app "System Events" to restart'", I have to issue "caffeinate -u". "caffeinate -d" or "caffeinate -i" are not sufficient.

See my comments at https://github.com/newmarcel/KeepingYouAwake/issues/92 for more details.

I guess I should use lldb to get a backtrace from a hung opengl test, figure out what API it's hung on, and then create a minimal app that sets the appropriate power management assertion, sleeps a bit, then calls the hanging API. I'll try to do that when I get a chance.

To work around it, I currently have this in a background script:

while true
   caffeinate -ud sleep 10

but that's not enough; CurrentPowerState dips down to 1 frequently on all systems (though I think only the 10.13 systems actually sleep the display and hang my tests).

Has anyone else run into this? Any suggestions how I can diagnose this further?

  • Have you considered trying a 3rd party app like Caffeine or Amphetamine for the 10.13 machines?
    – Natsfan
    Nov 21, 2017 at 16:46
  • 1
    Second @jmh's sugggestion, but also add "Anti Sleep" (has a Z in a circle I believe) which seems to work on 10.13, though I haven't paid attention to the screen blanking as I was only concerned that the CPU didn't sleep (read: remote desktop from somewhere else). But one question otherwise: if you're looking to have all these machines keep their displays operating, have you set the System Preferences -> Power -> Screen Sleep Timeout to "never"? If this is a bug in macOS that the timeout overrides the caffinated settings, then at least this would get around that for now?
    – bjb
    Nov 21, 2017 at 18:14
  • 3
    I just use Apple's caffeinate because it should suffice, and I like to avoid 3rd party gui apps. And yes, I set System Preferences to never sleep or blank the display.
    – Dan Kegel
    Nov 22, 2017 at 6:28

1 Answer 1


I found that caffeinate would not work for me in Catalina or Big Sur. I've found Amphetamine works just fine and I've had zero problems with it.

  • 1
    I use Amphetamine on my M1 Mac Air and find that it works perfectly as well. Nov 8, 2021 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .