Last active
August 24, 2017 17:54
-
-
Save gustavonovaes/a69781c4efe5231075ef94200ab28856 to your computer and use it in GitHub Desktop.
Guarda log do horário que o ping ao host falha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
host=$1 | |
log_path=$2 | |
if [ ! -f $log_path ]; then | |
touch $log_path | |
fi | |
store_fail() { | |
date +"%Y-%m-%d %H:%I:%S" >> $1 | |
} | |
while true; do | |
if ! ping -c 1 -W 1 $host &> /dev/null; then | |
store_fail $log_path | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment