The second reason is that I work on a lot of servers and when a server is gone for a reboot, I can run this script and give the server IP as input hence I will get notified when server is back online.
++++++++++++++++++++++++++++++++++++++
#!/bin/bash
echo "Enter ip/domain name"
read a
HOSTS=$a
COUNT=4
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 4 ]; then
# 100% Up
echo "Host : $myHost is Working (ping Sucess) at $(date)"
fi
done
++++++++++++++++++++++++++++++++++++++