LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 12-03-2007, 11:19 AM   #1
blackmamba11
LQ Newbie
 
Registered: Dec 2007
Posts: 1

Rep: Reputation: 0
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.
 
Old 12-03-2007, 11:51 AM   #2
polymath69
LQ Newbie
 
Registered: Oct 2004
Distribution: Debian, Ubuntu, DSL, TRK, etc.
Posts: 18

Rep: Reputation: 3
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.

/etc/rc0.d/S30shutdownonpurpose:
#!/bin/sh
touch /deliberateshutdown

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

/usr/local/bin/check-reboot:
#!/bin/bash

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
fi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
10.1 some errors after power outage future assassin Slackware 3 11-04-2005 05:33 PM
power outage jbzy3000 Linux - General 2 02-24-2005 09:11 PM
Power Outage horror Hampster Mandriva 5 01-13-2005 08:38 PM
Reboot after power outage oigeli Linux - General 1 12-02-2004 07:10 AM
Power Outage notslim General 30 08-28-2003 03:47 AM


All times are GMT -5. The time now is 10:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration