Skip to content

Instantly share code, notes, and snippets.

@bzon
Last active May 20, 2018 06:53
Show Gist options
  • Save bzon/2e731b7d5e7ba1d38e410b817f04a833 to your computer and use it in GitHub Desktop.
Save bzon/2e731b7d5e7ba1d38e410b817f04a833 to your computer and use it in GitHub Desktop.
Max retries with counter in bash!
ctr=0
max_retries=10
while [ {{condition}} ]; do
  ctr=`expr $ctr + 1`
  sleep 5
  if [ $ctr == $max_retries ]; then
    echo "max retries ($max_retries) reached"
    exit 1
  fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment