Created
June 12, 2024 13:55
-
-
Save bdashrad/656d55ffcb515f5d63d70a4529b3565d to your computer and use it in GitHub Desktop.
bash exponential backoff
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
#!/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