I was wondering if it's possible to detect a shutdown due to power loss on a Linux system. (Power loss defined as: pressing reset button, pressing power button, pulling the power cord) If so, how? (ie, if this is already something that people can do, what commands do I run?)The way I would imagine something like this working:When system comes back up, checks for an issued shutdown or reboot command, finds none.System checks for any sort of errors that have been logged that would require a reboot, such as kernel panic, etc (OOM maybe?) andfinds none.If no smoking gun found as described above, the system logs something like No cause for shutdown found, potential power loss detected.
Detecting a plug pulled scenario with Linux
logs;shutdown