Created
May 6, 2015 10:39
-
-
Save tekei/239b29d66b6f7c2a20f9 to your computer and use it in GitHub Desktop.
pingが通るまで待つ処理。jenkinsからのサーバ自動起動用。
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 | |
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