Last active
April 2, 2019 13:45
-
-
Save leviathan747/44dd2aec55f2d0c8f391844ce6f7b0a1 to your computer and use it in GitHub Desktop.
Ping a host every ten seconds and notify when it becomes unreachable
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/bash | |
if [[ $# != 2 ]]; then | |
echo "Usage:" | |
echo "watchbuild <host> <delay>" | |
exit 1 | |
fi | |
sleep $2 | |
while true; do | |
ping -c 1 $1 &> /dev/null | |
if [[ 0 != $? ]]; then | |
osascript -e 'display notification "Build has finished and server is shutdown." with title "Build Server Complete"' | |
exit 0 | |
fi | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment