After the computer shuts down suddenly unexpectedly without notification, is there a way to know the reason (read messages) the next time when I boot? My computer frequently shuts down, and I don't even know if it is a software problem, a hardware problem, or a firmware problem.
That would generally depend on your operating system, the type of computer you're using, and how abrupt the reboot was.
Many Unix-like operating systems (including the popular Linux-based ones) keep their logs in
/var/log. On some others,
/var/adm is the standard location. The specific files stored there depend on the OS, distribution and configuration. Look for
kernel.log, then try
Some non-Linux Unices can produce a full report of a crash whenever this happens. Check the OS docs on where the crash dump is stored, and how to read it.
If your computer has server management board, IPMI board, or somesuch, the reason for the reboot may be recorded there. Check the logs via the web interface or
ipmitool. If your mainboard has a dumber watchdog, the watchdog may be responsible for the reboot but this won't be logged.
If you still can't find any information, there are two cases: either the reboot is too sudden for the logs to be written (consider mounting your
sync temporarily — it's a serious performance hog), or there are no logs to be written. In the latter case, the issue is either a very low-level hardware fault or a power supply issue (e.g. the POWEROK signal from the power supply de-asserting and causing a hardware reset, or a half-dead laptop battery behaving strangely — the laptop I'm on right now has been known to do this occasionally when running on battery power).