rebootnotify – email alert and log for reboot and shutdown

by brian on September 17, 2010

Ever wondered how long your system was down for while the techs were working on it? Whether your system crashed or was actually shut down?
Or just want to make sure you’re aware of reboots?

This script helps in two ways:

  • It sends an email to a configurable email address when the system is shutdown or rebooted;
  • It permanently logs shutdowns and reboots in /var/log/shutdowns

You can change the email notification target by editing the main script (not the best) or by creating a file in /etc/sysconfig/rebootnotify as in:

echo NOTIFYPERSON=ouradmin@company.com > /etc/sysconfig/rebootnotify

Install via:

cp rebootnotify /etc/init.d
chmod 755 /etc/init.d/rebootnotify
chkconfig rebootnotify on

Once rebootnotify is installed you will be notified via email on every system reboot.

Download rebootnotify [1158 downloads] txt
  • Rob

    Hi – this looks really good, but for some reason it isn’t working for me. Using centos.. i go and type reboot, and I do not receive any emails (however, I am getting emails from my other scripts, such as root logins – so email is working. Is there another requirement that isn’t listed here?
    It also isn’t creating a shutdowns file.. i created an empty file myself as a test, but still nothing being updated in that empty /var/log/ file.
    Rob

    • Looks like it isn’t running. Check that you’ve done the “chkconfig” line and that the symbolic links exist in the appropriate directories.

  • JoshI

    Big newby question here…

    Where should this .txt file go and should it be changed in any way?
    When I run this command

    root@server1 [~]# cp rebootnotify /etc/init.d

    it returns:

    cp: cannot stat `rebootnotify’: No such file or directory

    I put the file in the root directory of the server before running that command.

    Thanks,
    Josh

    • Josh,

      Simply download the text file and rename it to “rebootnotify” then follow from there on. Make sure you run “chmod 755 /etc/init.d/rebootnotify” and the rest of the commands.

      Take care,

      Brian

  • Pingback: Sandino's Blog - rebootnotify – email alert and log for reboot and shutdown()

  • Hello,

    I suppose it needs sendmail running on the server in order to send the email? I am not that expert, so forgive me if my question is stupid

    Thanks
    Nikos

    • Not explicitly; it actually calls the system mail script, which uses whatever mail transport you are using (sendmail, exim, postfix, whatever)…

Previous post:

Next post: