Esto está hecho para sistemas que usen upstart. La idea es que el server mande un correo cuando el equipo está arrancando, cuando va a reiniciar o cuando se va a apagar (si le da tiempo de mandar el correo…)
[root@server ~]# cat /etc/init/notify.conf start on runlevel exec /usr/local/scripts/notifyScript $RUNLEVEL
[root@server ~]# cat /usr/local/scripts/notifyScript
#!/bin/bash
LOGFILE=/var/log/notify.log
EMAIL=myemail@address.com
RUNLEVEL=$1
case "$RUNLEVEL" in
[12345])
[[ "X"$RUNLEVEL == "Xunknown" ]] && exit
echo `date +[%F\ %a\ %T]`" - starting. Runlevel: "`runlevel` >> $LOGFILE
echo `tail -1 $LOGFILE` | mail -s "[`hostname`] - starting system" $EMAIL
;;
[06])
[[ "X"$RUNLEVEL == "X6" ]] && ACTION="rebooting" || ACTION="halting"
echo `date +[%F\ %a\ %T]`" - $ACTION. Runlevel: "`runlevel` >> $LOGFILE
echo `tail -1 $LOGFILE` | mail -s "[`hostname`] - $ACTION system" $EMAIL
;;
esac
chmod +x /usr/local/scripts/notifyScript
Enviar correo en shutdown/reboot/poweron