CentOS – Why Did Production Server Reboot?

centoslogging

I have a CentOS 5.2 box running my production web server (Apache 2 + Mongrel_cluster) for a Ruby on Rails project. The machine is hosted by GoDaddy.com and is a "virtual private server". The system periodically reboots on its own (maybe once every 6 months). I have two questions:

  1. How can I determine why my machine rebooted?
  2. Is there a good way to automagically notify me (i.e. via e-mail) when the system reboots?

Best Answer

  1. Check /var/log/messages for the suspected time it rebooted
  2. Put a one-liner in /etc/rc.local like:

    /bin/date +%F_%T | /bin/mail -s "myhost was rebooted" me@example.com

Cheers