Has your Mac computer ever mysteriously shutdown? Did you ever come back to your computer and noticed it rebooted?
Understanding the cause of the shutdown is the first step to making sure it doesn't happen again. When working on a Mac computer, the Console application should contain this information. Unfortunately, the Console is flooded with messages, making it painfully difficult to find any information.
Instead, open up a terminal and type in the following command:
log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h
Assuming your computer was restarted in the twenty-four hours, you should find one or several messages like this :
2018-10-08 21:54:20.691898-0400 0xa3 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: 3
2018-10-09 07:05:45.732682-0400 0xa3 Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: 5
2018-10-09 19:45:02.003738-0400 0x373fc Default 0x0 0 0 kernel: (AppleSMC) Previous shutdown cause: 5
The number next to the "Previous shutdown cause" indicates why the computer shutdown. You can look up the number in a table like this one. In my case, I used a hard shutdown and two "normal" shutdown on my computer.
Disclamer : Found the original info here.