Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I've set the BIOS of my server to automagically resume the last state (running/switched off) after a powerloss.

Now, how can I send myself an E-Mail when the system has resumed after a powerloss ?

I know it is possible, since my Synology Diskstation can do it (which is how I got the idea in the first place). Sadly I'm not able to reverse-engineer how it does it.

share|improve this question
up vote 1 down vote accepted

Add an RC script or equivalent. Have it touch a file on normal shutdown. On startup, have it check for the file, and send an email if the file is not there. E.g:



if [ ${1} = "stop" ] then touch "${SHUTDOWNFILE}"
elif [ ${1} = "start" ] 
    if [ ! -e "${SHUTDOWNFILE}" ] 
        mail -s "Power failure, recovered"
        rm "${SHUTDOWNFILE}"

(You'll probably have to debug it, and pay attention to security to avoid accidentally giving users access to create files to conflict with this one)

share|improve this answer
Very simple solution indeed. I replaced mail with sendemail, because mail doesn't work for me. – Quandary Nov 16 '10 at 7:28

Just add something like this to /etc/rc.local:

echo "Subject: `/bin/hostname` has booted @ `date '+%Y/%m/%d %H:%M:%S'`"|/usr/lib/sendmail -i

This will email every time it boots, not just after power loss. More logic will be required if you only want emails following power loss. Personally, I like to know whenever one of my servers reboot - especially if it wasn't an intentional reboot.

share|improve this answer
This is a step into the right direction. But I only want to notify after power loss, not on every bootup. The tricky part is finding out how to distinguish the boot state/get the error message. – Quandary Nov 13 '10 at 19:38

You need an Internal IPMI on the system hardware ( which can report failures of powerloss and hardware failure via email)

Secondly and i think most importantly.. and external system which checks health of systems..

Nagios & Cacti both offer these functions..
Cacti actually being the simpler of the two ( Nagios can be quite complicated to maintain ) Using SNMP or simple pings.. ( can also be other services )

Basically the tool allows you to poll every ( determined ) minutes.. for a response.. After (determined) failures, it sends you an email..

This is a typical systems administrators set of tools for notifications.. :D

share|improve this answer
Or use a simple method which is basically offering no notification of failure.. which is shown in other posts.. :D – Arenstar Nov 13 '10 at 18:37
Sounds like a windows solution - expensive, inefficient, superfluous, and almost certainly not working with cheap hardware. If I want to monitor if the system is up, I use ping or a periodic http-get service with a timeout (after all, I want to know whether the webserver runs...). That's cheap and efficent. All I want right-now is sending an email on powerfail-resume. – Quandary Nov 13 '10 at 19:36
Like i said.. if you dont want a serious checking/notification system then run some thing like ErikA suggested.. I gave you the correct answer as how an autonomous system should be built.. There is a reason we all should run these things in a system administration environment.. BTW, this is classic unix solution, value your integrity before speaking out... – Arenstar Nov 13 '10 at 19:41
@Arenstar - there's nothing un-serious about my solution. The OP didn't mention having an iLOM/ipmi setup, so I proposed a solution that would work without any specific hardware dependencies. In fact, I use both solutions (iLOM and the rc.local script, along with external monitoring by Nagios) on all of the ~150 servers I manage. – EEAA Nov 13 '10 at 20:24
@Quandaray - Whether or not your hardware supports ipmi or some other form of lights-out management has nothing to do with what operating system you're running. In fact, these management cards live completely outside of your system's motherboard. Sure, hardware that supports them is not cheap, but as Arenstar says, it's as close to the "right" way to do things as one can get. If your hardware doesn't support impi, then you'll need to use something like the snippet I posted (or an adaptation thereof). – EEAA Nov 13 '10 at 20:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.