How to get previous shutdown cause

shutdownunix

I try to get previous shutdown cause and when it happened but i don't know correct syntax.

syslog -k Sender kernel ???

I need to get date and time in start of the row and shutdown cause number in end of the row which can be negative number too.

Best Answer

I usually just run

sudo grep "Previous shutdown cause" /var/log/system.log

or (if the above returns empty)

sudo zgrep "Previous shutdown cause" /var/log/system.log.*.gz