My iMac has insomnia

Using a 2017 iMac 27 on whatever the most recent non-beta macOS version is, and it’s harder to get to sleep than a toddler on a sugar rush.

I tell it to turn off the screen after 10 minutes. It keeps it on way longer. I manually choose the :apple: menu, Sleep option. Screen goes blank, I turn off the office lights and as I walk down the hallway, the screen turns itself on again!

Any suggestions on what may cause this behaviour?


This terminal command will tell you what processes want your Mac awake:

pmset -g assertions

1 Like

Hmmm… seems it might be Bluetooth LE or USB media? Not sure I’m reading the output right, so dropping it here. (Connected via Screens at the moment.)

airwhale@iMac5k ~ % pmset -g assertions

2022-02-28 19:46:38 +0100

Assertion status system-wide:

BackgroundTask 0

ApplePushServiceTask 0

UserIsActive 1

PreventUserIdleDisplaySleep 0

PreventSystemSleep 1

ExternalMedia 1

PreventUserIdleSystemSleep 1

NetworkClientActive 0

InternalPreventSleep 1

Listed by owning process:

pid 90532(ScreensharingAgent): [0x0009982700099ef0] 00:00:45 UserIsActive named: "Remote user active"

Timeout will fire in 554 secs Action=TimeoutActionRelease

pid 513(sharingd): [0x0009983b00019f3f] 00:00:26 PreventUserIdleSystemSleep named: "Handoff"

pid 158(WindowServer): [0x0009982b00099efc] 00:00:01 UserIsActive named: " serviceID:1000002c0 name:IOHIDSystem product:NULL eventType:1"

Timeout will fire in 599 secs Action=TimeoutActionRelease

pid 466(nsurlsessiond): [0x00099852000b9f49] 00:00:02 BackgroundTask named: "NSURLSessionTask A9E7AF43-6468-47F4-878A-FB083F12E4E6"

Timeout will fire in 10798 secs Action=TimeoutActionTurnOff

pid 466(nsurlsessiond): [0x00099853000b9f4d] 00:00:01 BackgroundTask named: "NSURLSessionTask 41AF84E1-96C9-460F-A27B-E5844731FCC7"

Timeout will fire in 10798 secs Action=TimeoutActionTurnOff

pid 462(cloudd): [0x0009985300019f4a] 00:00:02 PreventUserIdleSystemSleep named: "NSURLSessionTask EF608FF7-0EAC-4B06-890D-1C405C753625"

Timeout will fire in 10798 secs Action=TimeoutActionTurnOff

pid 462(cloudd): [0x0009985300019f4b] 00:00:01 PreventUserIdleSystemSleep named: "NSURLSessionTask 324AEFC7-9586-4FB6-847E-2B045DFA3007"

Timeout will fire in 10798 secs Action=TimeoutActionTurnOff

pid 462(cloudd): [0x0009985300019f4c] 00:00:01 PreventUserIdleSystemSleep named: "NSURLSessionTask F3B366D0-9807-4E83-9710-D4AA558D01BE"

Timeout will fire in 10798 secs Action=TimeoutActionTurnOff

pid 462(cloudd): [0x0009985400019f4e] 00:00:01 PreventUserIdleSystemSleep named: "NSURLSessionTask D82077FA-72CE-42DE-8E61-2FF1A4428B65"

Timeout will fire in 10799 secs Action=TimeoutActionTurnOff

pid 150(bluetoothd): [0x0009973e00099e7e] 00:00:24 UserIsActive named: "Bluetooth LE HID Activity"

Timeout will fire in 576 secs Action=TimeoutActionRelease

pid 90531(screensharingd): [0x0009982700079eee] 00:00:46 PreventSystemSleep named: "Remote user is connected"

pid 90531(screensharingd): [0x0009982700099eef] 00:00:00 UserIsActive named: "Remote user active"

Timeout will fire in 600 secs Action=TimeoutActionRelease

pid 99(powerd): [0x0000001400088016] 366:21:49 ExternalMedia named: ""

pid 99(powerd): [0x0009982a000d9ef2] 00:00:42 InternalPreventSleep named: ""

Timeout will fire in 3 secs Action=TimeoutActionRelease

pid 99(powerd): [0x0009982a000d9ef1] 00:00:42 InternalPreventSleep named: "PM configd - Wait for Device enumeration"

Assertion applied on Battery power also

Kernel Assertions: 0x104=USB,MAGICWAKE

id=503 level=255 0x4=USB creat=2022-02-13, 13:31 owner=USB 2.0 BILLBOARD

id=504 level=255 0x4=USB creat=2022-02-13, 13:31 owner=My Book 25EE

id=505 level=255 0x4=USB creat=2022-02-13, 13:34 owner=Schiit USB Multibit

id=506 level=255 0x100=MAGICWAKE creat=2022-02-13, 13:29 mod=2022-02-28, 19:55 description=en0 owner=en0

Idle sleep preventers: IODisplayWrangler

Put the Mac to sleep as you normally do, then, when it wakes up, immediately try these:

pmset -g log |grep "Wake Request"

log show |grep -i "Wake request"

1 Like

@jec0047 has some good troubleshooting ideas.

Could be a Bluetooth accessory waking it up, such as headphones.

I’m assuming you don’t have caffeine, amphetamine or anything like that running?

The Bluetooth seems, from my own experience and from searching the 'net for ideas to resolve, often showing up on reasons for the Mac coming out of sleep. But, what I’ve never seen suggestions for what to do about a Bluetooth accessory and insists to wake up apparently on its own. For me it’s usually in the middle of the night when the computer is not being used.

Any ideas or suggestions?

Oh, the joy of troubleshooting. Of COURSE it behaves when I put it to sleep right now :slight_smile: I’m on to you, darn computer.

Will continue the search and report back with anything that works. Thanks for your patience, my Unix command line skills are pretty rusty.

I wasn’t sure, so I had to check for Caffeine which I have used in the past. It IS installed, but not running - good tip though, so thanks!

I have been wondering about Bluetooth stuff, I am using keyboard and mouse from Logitech, but they usually behave well in my experience.

Ok, there I caught it. Seems like they are all Apple processes.

2022-03-01 10:48:59 +0100 Wake Requests       	
[process=mDNSResponder request=Maintenance deltaSecs=7197 wakeAt=2022-03-01 12:48:56 info="upkeep wake"] 
[process=dasd request=SleepService deltaSecs=14561 wakeAt=2022-03-01 14:51:40 info=""] 
[*process=dasd request=TimerPlugin deltaSecs=1797 wakeAt=2022-03-01 11:18:56 info=""] 
[process=NotificationCenter request=Maintenance deltaSecs=33086 wakeAt=2022-03-01 20:00:26 info=""] 
[process=powerd request=AdaptiveWake deltaSecs=91300 wakeAt=2022-03-02 12:10:40] 
[process=powerd request=UserWake deltaSecs=33060 wakeAt=2022-03-01 20:00:00 info=",416"]

This is output from the pmset command.

I see the Photos Face Analysis process in there and FYI, was not running at the time, so guessing this is a daemon process.

Were you able to run the commands immediately after the Mac awoke? The reason I ask is that none of the timestamps are very close to 10:48:59.

Yes, I ran this max 20 seconds after a spontaneous wake. Weird, right?

It looks like if you add the “deltaSecs” to 10:48 you get the “wakeAt” value (I didn’t verify this to the second but it looks about right). So I believe the log entry is telling us “Here are the pending wake requests at 10:48 and (for example) the wake request logged by the first entry will go off in 7197 seconds, or at 12:48." So what we need now is the time the Mac actually awoke and then we should be able to guess which request actually caused the wakeup.

BTW, as you more or less inferred, a process whose name ends with a “d” is usually a daemon (like “

1 Like