I am looking for a (hopefully) simple script that sends out an email on system restart and system halt. Unfortunately, Google hasn't been helpful in this search (or my Google-fu is off today). Does anyone have a script - either cron, init.d or something else entirely - that will send out an email when a system shuts down and again when it comes back up? Same for restart. I'm also open to being pointed to a good resource. Like I mentioned before though, Googling for "send email on restart linux" hasn't turned up anything useful thus far. I realize it would send two emails each time - however, this does two things for me 1.) Says the restart was successful 2.) Identifies when there was a power failure (ie. I only got the start up email, but no shutdown). It may matter - I am using Red Hat based systems - CentOS 5.x and Fedora versions 5-11 (I know, its a big range and some need to be updated). Thank you
Look at the mail command, or the program mailm. Then you'll want to write your simple script and put a link to it in rc0.d, rc3.d (and/or rc5.d) and rc6.d - one for shut down, one for restart.
Check 'monit', it does the same thing you want, and lots of other useful alerts. http://www.howtoforge.com/server-monitoring-with-munin-and-monit-on-centos-5.2 Hope this helps. Dipesh
id10t, your response was able to give me a better idea what to Google for, thank you. I found this early this morning: Email on shutdown and restart (Linux) Thanks for the help and idea.