Skip to content

Instantly share code, notes, and snippets.

@roniemicro
Created January 15, 2015 06:27
Show Gist options
  • Save roniemicro/892fab3d7823a0c1fd05 to your computer and use it in GitHub Desktop.
Save roniemicro/892fab3d7823a0c1fd05 to your computer and use it in GitHub Desktop.
while true
do
if nc -w 2 server2 9999 < /dev/null > /dev/null 2>&1
then
# Service is currently running
[ "$PREV" = "NOT" ] && /path/to/your/script
PREV="RUNNING"
else
# Service 2 is not running on server2
PREV="NOT"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment