Couldn’t stay awake any longer: Energy Saver ignored

After long-standing problems with the sleep settings for this iMac (iMac17,1), I don’t let it go to sleep at all. When I did let it sleep, no matter what I set the disk sleep option to, it would sleep the hard disk in its Fusion Drive. Knowing that waking a hard disk up tends to wear it out, I didn’t want that.


So for many months, it has been set to put the display to sleep after 3 hours, to prevent the computer from sleeping, and not to put its hard disk to sleep. When I come down in the morning and wake its display up, I don’t hear the hard disk running back up to speed, and checking its logs shows that Time Machine has run dutifully throughout the night.

When I got up on Monday morning and woke my iMac up, I was surprised to hear its hard disk run up from sleep. Shortly afterwards, Time Machine started making quite a large backup. So I checked my logs, using LogLogger, only to discover that this was the first backup that it had run since 23:22 the previous night.

Yes, despite those settings in Energy Saver being unchanged, my iMac had gone to sleep, its hard disk with it.

There was no harm done apart from losing another few hours from the life of its hard disk, but I’m totally baffled that macOS seems to have defied the Energy Saver settings. When I went to check those, in /Library/Preferences/SystemConfiguration/, I was surprised to see that file gone, leaving a shadow file in its place, with ~previous appended to its extension.

As far as I can tell, the update to macOS Sierra 10.12.2 moved the location of the Energy Saver settings file from there back to /Library/Preferences/ Having found that, my settings definitely contain the entries
<key>Disk Sleep Timer</key>
<key>System Sleep Timer</key>

which should prevent both system and hard disk sleep. Even in the settings for use when running off my UPS, disk sleep is fixed at 0, which should prevent hard disk sleep.

So, what happened in the logs?

At 06:39, macOS suddenly decided that it was going to sleep:
06:39:28.13 sharingd[434]: [] Device can sleep
06:39:34.30 securityd[120]: [] can system sleep
06:39:41.90 LaterAgent[567]: (StoreFoundation) [] LAPowerEventObserver: System is considering sleep
06:39:34.66 securityd[120]: [] system will sleep
06:39:34.66 securityd[120]: [] 0x7fff51908b30 will sleep
06:39:28.51 sharingd[434]: [] Device will sleep

eventually reaching
06:39:48.62 kernel[0]: PMRD: System Sleep
06:39:48.64 kernel[0]: IOCPUSleepKernel
06:39:48.64 kernel[0]: IOPlatformSleepAction -> AppleSMBusControllerICH
06:39:48.64 kernel[0]: IOPlatformSleepAction -> AppleThunderboltHAL
06:39:49.17 kernel[0]: (AppleThunderboltNHI) AppleThunderboltGenericHAL::lateSleep - complete - took 532 milliseconds
06:39:49.17 kernel[0]: (AppleACPIPlatform) ACPI SLEEP

When I rudely woke it up after this catnap:
07:21:58.85 kernel[0]: (AppleSMC) Previous sleep cause: 5
07:21:58.96 kernel[0]: PMRD: prevent idle sleep list: IODisplayWrangler+ (1)
07:21:58.96 kernel[0]: prevent idle sleep list: IODisplayWrangler+ (1)
07:21:59.70 kernel[0]: (PromiseSTEX) STEX : setPowerState : 2, (0 = sleep , 1 = pause, 2 = wake)

Apparently code 5 for a previous sleep cause means a user-initiated or -controlled event, rather than power-related. At no time had my Mac restarted (it has now run 23 days without shutdown or restarting).

So there is a ghost in this machine, and it seems to get tired on occasion. Or can you think of a better explanation?