Skip to content

Instantly share code, notes, and snippets.

@tekei
Created May 6, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekei/239b29d66b6f7c2a20f9 to your computer and use it in GitHub Desktop.
Save tekei/239b29d66b6f7c2a20f9 to your computer and use it in GitHub Desktop.
pingが通るまで待つ処理。jenkinsからのサーバ自動起動用。
#!/bin/sh
PING_TARGET=$1
COUNT_LIMIT=$2
echo "try ping to ${PING_TARGET}"
COUNT=1
while true;do
ping -c 3 ${PING_TARGET} >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
echo "ping OK"
exit 0
fi
COUNT=`expr ${COUNT} + 1`
if [ ${COUNT} -gt ${COUNT_LIMIT} ]; then
echo "ping NG"
exit 1
fi
echo "sleep count : ${COUNT}"
sleep 3
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment