Skip to content

Instantly share code, notes, and snippets.

@bdashrad
Created June 12, 2024 13:55
Show Gist options
  • Save bdashrad/656d55ffcb515f5d63d70a4529b3565d to your computer and use it in GitHub Desktop.
Save bdashrad/656d55ffcb515f5d63d70a4529b3565d to your computer and use it in GitHub Desktop.
bash exponential backoff
#!/usr/bin/env bash
# example exponential backoff in bash
for (( i=0; ; i++)); do
TIME=$(echo "2^$i" | bc)
[ $TIME -ge 32 ] && exit 1
sleep $TIME
// do stuff && break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment