MacBook Pro tries to shutdown every X hours

My Macbook Pro is trying to shutdown itself every X amount of hours, is there a way to check in the logs what process is triggering the shutdown process?

I can see the following in the logs, but not much else:

Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CrashReporter/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 50
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 pruneDirectoryNDaysRead cap 7
Mar 28 11:10:09 CCDaemon::shutdown is fired
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CrashReporter/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 50
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CrashReporter/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 50
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CrashReporter/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 50
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CrashReporter/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 50
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CrashReporter/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 50
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CrashReporter/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 50
Mar 28 11:10:09 cleanCaptureDirectories /Library/Logs/CoreCapture
Mar 28 11:10:09 numberOfDirArrayEntriesMax: 50, numberOfDirArrayEntries 0
Mar 28 11:10:09 CCProfileMonitor::freeResources Entered
Mar 28 11:10:09 CCProfileMonitor::freeResources done
Mar 28 11:10:09 CCDataTap::profileRemoved, Owner: com.apple.iokit.IO80211Family, Name: AssociationEventHistory
Mar 28 11:10:09 CCLogTap::profileRemoved, Owner: com.apple.iokit.IO80211Family, Name: IO80211AWDLPeerManager
Mar 28 11:10:09 CCLogTap::profileRemoved, Owner: com.apple.driver.AirPort.Brcm4360.0, Name: DriverLogs
Mar 28 11:10:09 CCLogTap::profileRemoved, Owner: com.apple.iokit.IO80211Family, Name: OneStats
Mar 28 11:10:09 CCIOReporterFormatter::refreshSubscriptionsFromStreamRegistry clearing out any previous subscriptions
Mar 28 11:10:09 CCIOReporterFormatter::addRegistryChildToChannelDictionary streams 24
Mar 28 11:10:09 CCDataTap::profileRemoved, Owner: com.apple.driver.AirPort.Brcm4360.0, Name: StateSnapshots
Mar 28 11:10:09 CCLogTap::profileRemoved, Owner: com.apple.iokit.IO80211Family, Name: ControlPath

I've seen other answers but they are for Macs that power off completely, mine is not shutting down cause the iTerm popup is stopping it. But then all other apps are closed.


Solution 1:

I was having a similar issue because occasionally I would unlock my laptop to find a number of applications had closed, but a "shutdown was prevented due to a running task that didn't close" message.

I then found this article explaining what was going on.

It wasn't trying to shutdown, but logout because of the "Log out after X minutes of inactivity" configuration.

To fix the issue, I did the following:

  1. Open System Preferences.
  2. Select Security & Privacy.
  3. Unlock the padlock (bottom left) by clicking it and entering password.
  4. Select Advanced... (bottom right).
  5. Uncheck or modify this setting appropriately:

enter image description here

Solution 2:

Check if a shut down schedule is set in System Preferences → Energy Saver → Schedule.

Energy Saver schedule