Skip to content

Instantly share code, notes, and snippets.

@0xKD
Created September 24, 2017 02:46
Show Gist options
  • Save 0xKD/0c427c738c4cbbcb56f08b6d75d70643 to your computer and use it in GitHub Desktop.
Save 0xKD/0c427c738c4cbbcb56f08b6d75d70643 to your computer and use it in GitHub Desktop.
Find shutdown cause macOS

Run this

log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h

Check reason code in following list:

Code	Description	Solution
5	Correct Shut Down.	Shutdown was initiated normally, from the OS X Shut Down menu or other shutdown command such as /sbin/shutdown. This does not indicate an issue with your system.
3	Hard shutdown.	Check the power button if you did not perform a hard shutdown yourself. It could be the case that the power button stuck down and forced a shutdown.
0	Power disconnected.	Check power supply/battery on a laptop, or the power supply for a Mac without a battery. On a laptop, the Mac should hibernate before the battery becomes so discharged it is unable to shutdown correctly, therefore if you see this shutdown cause on a laptop it may indicate a hardware issue with the battery or with the battery controller for reading the charge. Try resetting the SMC by connecting the switched off computer to power, holding ⌃control+⌥option+⇧shift and pressing power.
-3	Multiple temperature sensors exceeded the defined limit.	Hold D on boot to run Apple Diagnostics and follow the instructions if any errors are found. If the issue persists, make an appointment at an Apple Store. For Authorized Service Providers, Run Apple Service Diagnostics to check which sensor went beyond expected thermal limits.
-60	Bad master directory block (badMDBErr).	Back up your data, erase the disk and reinstall macOS. If you continue to run the system, data loss may ensue. Use Time Machine to keep a backup until you are able to erase and restore. A common symptom is being unable to repair with Disk Utility — as such, erasing the disk is required as mentioned.
-61	Watchdog timer detected unresponsive application, shutting down the system.	Troubleshoot for stuck application, startup item and any loading preferences. Boot to Safe Mode by holding ⇧shift on boot which disables most startup items and daemons. If the problem does not occur, try a new user account.
-62	Watchdog timer detected unresponsive application, restarting the system.	The system will automatically restart after this shutdown cause, unlike -61. Troubleshooting applies the same for cause -61. -61 is used where the system believes it cannot automatically recover from this, whereas -62 is used where the system determines it is likely to be resolved after restart.
-65	unknown	Potentially linked to operating system issue. Try reinstalling macOS as fresh or booting from clean install on an external drive.
-71	SO-DIMM Memory temperature exceeds limits.	If possible, swap memory module and check with known-good one to confirm issue is with memory. Check fans physically and with an app such as iStat Menus to determine whether the fans are rotating correctly and being reported correctly. Check air flow: open device and clean airways.
-74	Battery temperature exceeds limits.	Reset the SMC by connecting the switched off computer to power, holding ⌃control+⌥option+⇧shift and pressing power. Swap battery and check with known-good one to confirm issue is with customer battery.
-75	Communication issue with AC adapter.	Check power/MagSafe connector (plug), adapter and cable. Make sure the adapter in use is an official Apple power supply. On MacBook Pro with USB-C, connect power to opposite side of laptop to determine if issue is with specific ports.
-78	Incorrect current value coming from AC adapter.	Make sure the adapter is an official Apple power supply. Check AC adapter plug and cable. Confirm current at the wall where the adapter is connected to.
-79	Incorrect current value coming from battery.	Check battery statistics: check if cycles are excessive and may indicate the battery needs replacing. Check the battery connection to logic board.
-86	Proximity temperature exceeds limits.	Check thermal contact with heatsink, fan connection and physical/reported activity.
-95	CPU temperature exceeds limits.	Check thermal contact with heatsink, fans. Reset SMC by connecting the switched off computer to power, holding ⌃control+⌥option+⇧shift and pressing power.
-100	Power supply temperature exceeds limits.	Check fans and air flow. Confirm power supply is official Apple. If MagSafe, remove any MagSafe adapters in use (e.g. MagSafe 1 to 2).
-103	Battery cell under voltage detected.	Check battery and replace with known-good. Perform one charge cycle, then try again.
-104	unknown	Possibly linked to battery issue. Perform one charge cycle and try D-boot to run diagnostics.
-108	unverified	Likely memory issue. Commonly occurs when RAM is full and there was an issue with paging. Can occur when the system is sleeping.
-112	unverified	Memory issue. Almost always occurs around -128, another memory issue. Almost certainly hardware fault. See -128 for troubleshooting.
-127	PMU forced shutdown.	Check power button on your hardware. Potentially fine if you forced shutdown, otherwise may be hardware/SMC issue.
-128	unknown	Possibly linked to memory issue. If the issue is persistent, try replacing the RAM with known-good if your hardware has removable RAM.
@jeffery9
Copy link

what means for -20?

➜ /etc log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h
Filtering the log data using "composedMessage CONTAINS "Previous shutdown cause""
Skipping info and debug messages, pass --info and/or --debug to include.
Timestamp Thread Type Activity PID TTL
2019-09-14 23:40:36.570273+0800 0xc3 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: -20
2019-09-15 11:41:24.815074+0800 0xc3 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: -20
2019-09-15 15:01:17.974234+0800 0xc3 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: -20
2019-09-15 18:20:28.584300+0800 0xc3 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: -20

@KirillKayumov
Copy link

@jeffery9 I'm experiencing the same -20 error. Did you fix it on your machine?

@pocketscience
Copy link

I'm also getting -20. Only occurs when I have a Emblaser laser engraver connected via USB. Even if the engraver is idle I'm still seeing reboots. Very frustrating.

@andreypopov
Copy link

+1, 3 times today -20

@vantagepoint05
Copy link

Hi,
My system had a kernel panic but its not showing in the report when i run the command ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment