Last active
September 9, 2021 07:20
-
-
Save volodymyr-mykhailyk/8bf7197a7970064cbab8272b2dbfb6d6 to your computer and use it in GitHub Desktop.
Shell to wait for url to respond
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 | |
ATTEMPTS_COUNTER=0 | |
URL=$1 | |
MAX_ATTEMPTS=${2:-10} | |
until $(curl --output /dev/null --silent --head --fail ${URL}); do | |
if [ ${ATTEMPTS_COUNTER} -eq ${MAX_ATTEMPTS} ];then | |
echo "Max attempts reached" | |
exit 1 | |
fi | |
printf '.' | |
ATTEMPTS_COUNTER=$((${ATTEMPTS_COUNTER}+1)) | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment