Skip to content

Instantly share code, notes, and snippets.

@volodymyr-mykhailyk
Last active September 9, 2021 07:20
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 volodymyr-mykhailyk/8bf7197a7970064cbab8272b2dbfb6d6 to your computer and use it in GitHub Desktop.
Save volodymyr-mykhailyk/8bf7197a7970064cbab8272b2dbfb6d6 to your computer and use it in GitHub Desktop.
Shell to wait for url to respond
#!/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