Stop process from preventing sleep on OS X I run a MacBook Pro with OS X 10.11. I've noticed the machine hasn't slept well last night. There were events logged every couple of seconds in system.log throughout the entire night that the lid was closed.

I think it might be that two processes are preventing sleep while on A/C.

# pmset -g
System-wide power settings:
[...]
sleep                10 (sleep prevented by UserEventAgent, UserEventAgent)


Can I stop these processes (or any other process) from preventing sleep?
There are dozens of things that can prevent sleep built into macOS, and third party software can also disable sleep.

The first troubleshooting step is to run this command in Terminal:

pmset -g assertions


That will list the reasons your Mac is not currently asleep. Normally running on battery power you should get:

Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     0
   NetworkClientActive            0

[further details removed for brevity]


Which means the only reason your mac isn't sleeping is due to user activity on the mouse/keyboard.

If you see something else (like PreventUserIdleSystemSleep) then your mac probably won't sleep at all and you should read the other details provided by pmset -g assertions to investigate further.