-   Linux - Server (
-   -   power outage (

blackmamba11 12-03-2007 11:19 AM

power outage
How can one tell if your linux server has experienced a power outage. For example, i have 2 servers in a datacenter. If the power goes out, is there a log that will tell me that the power went out unexpectedly?? I am using redhat enterprise 4 advanced server.

polymath69 12-03-2007 11:51 AM

Well, who -b will tell you when the system was last booted; you could have a script check this periodically and email you if it changes.

So something like a combination of the following would email you only on unexpected reboots.

touch /deliberateshutdown

crontab entry:
*/5 * * * * /usr/local/bin/check-reboot


if [ -f /deliberateshutdown ]; then
rm /deliberateshutdown
who -b > /var/run/lastboot
elif ! cmp /var/run/lastboot <(who -b) >/dev/null; then
mail root -s power <<<"There may have been a power outage"
who -b > /var/run/lastboot

All times are GMT -5. The time now is 06:22 PM.