Server Reboot Alert

I want to get an email alert from a cronjob when a server got rebooted unexpectedly. Please help. Thanks! :confused:

Using cron would be difficult since it runs jobs on a schedule - reboots don't normally happen that way.

Put a startup script which emails you when the server reboots. Since you didn't post what OS or version you are running, I can't give you specifics of where the script should go (For Solaris in /etc/rc2.d or /etc/rc3.d would be a good place).
You would want it to start after the network is up and running so putting it as S99some-name should work (again, it matters on what your OS is).

Create S99serverup in /etc/rc2.d would send a email to your address at your domain with the hostname and reboot as subject. No internal message but you can change that with information placed into another file if needed.

#!/bin/sh
/bin/mailx -s"`hostname` reboot" youremail@yourdomain.xxx < /dev/null
exit

My OS version is as below:

Linux jupiter 2.4.21-27.0.1.ELsmp #1 SMP Mon Dec 20 18:47:45 EST 2004 i686 i686 i386 GNU/Linux