Shutdown causes

Shutdown Causes in Mac OS
If you are having shutdown problems, use this command in the main user to find out the error codes, you can change the time to 1h, 24h, 72h or 2w or 1M or even " 1Y " the codes are generated in the terminal app. after that, collect the generated code and check the main errors in the table below, after the system crashes or recovers from a panicfull: 
log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h
This command is used if the mac does not recover after going to sleep or before going to sleep. Works for other occasions too ... you can also try this other command:
log show --predicate 'eventMessage contains "Previous sleep cause"' --last 24h
Error codes:
Code 	Description 	Notes and Possible Solutions
7 	thread cpu failure 	If this occurs during boot, try Safe Mode by holding on boot to limit what opens during boot. If while using the app, see if there is an update for the app by the developer, and leave a comment below with the app name and your Mac model.⇧shift
5 	Correct shut down 	Is it a 'clean' shutdown or hibernation by the user
3 	Hard shut down 	Iresulting from a hard reset or shutdown, check the power button and make sure it is not stuck, etc.
0 	Power disconnected 	AC power supply failure, check power supplies: cables, plug, magsafe. On a MacBook, this could be a battery issue, or battery controller (logic board). Try an SMC reset first or a battery replacement!
Multiple temperature sensors exceeded the defined limit. 	Run Apple Hardware Test or PC Doctor. Check fans/airflow/thermal paste. 	
-14 	Electricity spike/surge. 	On Mac Pro, this can indicate an electricity issue to the built-in power supply, or an issue with the power supply itself
-20 	Shutdown was initiated by BridgeOS T2. 	The T2 chip has initiated a shutdown.
Bad master directory block (badMDBErr). 	corrupted system or storage, Do not continue using the system, or you may experience data loss: Backup data to Time Machine, completely erase the disk and reinstall macOS system.. 	
Watchdog timer detected unresponsive application, shutting down the system.	Probably an application issue. Retry in Safe Mode, investigate stuck applications, investigate startup programs. Run MalwareBytes scan. 	
-63 	 	it could be the USB controller or another T2 related USB hardware issue. Check kernel logs to confirm
Watchdog timer detected unresponsive application, restarting the system. 	Same as -61, except the machine will restart automatically instead of shutting down. 	
 	Potentially linked to OSX issue. Try reinstalling macOSX from a clean install on an external drive. 	
SO-DIMM Memory temperature exceeds limits. 	Try to reset the smc, if not, check the memory if possible replace it to see if the problem persists. If so, check the logic board for oxidation or dust. 	
Battery temperature exceeds limits. 	Perform SMC Reset. Possible need for battery replacement? 	
Communication issue with AC adapter. 	Use an official Apple power adapter. If on a USB-C model, try charging with the ports on the opposite side (to test port failure on one side). 	
Incorrect current value coming from AC adapter. 	Use an official Apple power adapter. Check building power/current at wall? 	
Incorrect current value coming from battery. 	Check the battery connection. Check battery cycles (may simply need replacement). 	
Proximity temperature exceeds limits. 	Check fans/airflow/thermal contact and thermal paste. 	
CPU temperature exceeds limits. 	Check fans/airflow. Check thermal paste between heatsink. Reset SMC. 	
Power supply temperature exceeds limits. 	Try resetting the smc, if that doesn't work, check the fans/airflow on the iMac. Check the magsafe on the MacBook for dirty, oxidized or burnt and remove MagSafe 1 to 2 or similar if in use.	
-102 	overvoltage 	Safety shutdown related to AC or Battery overvoltage protection
Battery cell under voltage detected. 	Replace the battery. 	
 	Possible battery issue? Try a complete charge cycle, or Apple Diagnostics before replacing. 	
 	Probably memory related? Could be running out of RAM (and Paging fails). Can occur during sleep. 	
 	Probably memory related? If on 2012-2013 15” MBP, probably GPU related. Usually occurs alongside -128. 	
PMU forced shutdown. 	Possibly fine if you performed a hard shutdown? If not, check power button (make sure it isn’t stuck).
Otherwise, could be a logic board issue. 	
 	possibly the battery is at the end of its life, but it can also occur when the SMC initiates an automatic reboot after a kernel panic. occurs similar to -112. 	
(via ifixit
https://georgegarside.com/blog/macos/shutdown-causes/
Almost every day I use this page to be able to diagnose my services, thanks to everyone who contributed to this site. Ad Victoriam!
by Pingas
Category:Mac
Category:MacBook
Category:Troubleshooting Guide