Want to receive an email any time your linux server reboots? Just create this script…
sudo nano /usr/local/sbin/startupemail.sh
Here’s the code for the script…
#!/bin/sh
# Lets things startup
sleep 60
# Get info
IP="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"
HOSTNAME=`hostname`
#Send email
echo "IP: $IP, Host: $HOSTNAME" | mail -s "Server Started" [email protected]
Make sure to make it executable…
sudo chmod u+x /usr/local/sbin/startupemail.sh
Then add it to your /etc/rc.local file
Please remember to subscribe to the newsletter to stay up to date!You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...