Linux Startup Email

Want to receive an email any time your linux server reboots? Just create this script…

sudo nano /usr/local/sbin/

Here’s the code for the script…


# Lets things startup
sleep 60

# Get info
IP="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"

#Send email
echo "IP: $IP, Host: $HOSTNAME" | mail -s "Server Started"

Make sure to make it executable…

sudo chmod u+x /usr/local/sbin/

Then add it to your /etc/rc.local file

Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

Leave a Reply