Skip to content

Instantly share code, notes, and snippets.

@leviathan747
Last active April 2, 2019 13:45
Show Gist options
  • Save leviathan747/44dd2aec55f2d0c8f391844ce6f7b0a1 to your computer and use it in GitHub Desktop.
Save leviathan747/44dd2aec55f2d0c8f391844ce6f7b0a1 to your computer and use it in GitHub Desktop.
Ping a host every ten seconds and notify when it becomes unreachable
#!/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