Last active
July 9, 2017 10:09
-
-
Save isjerryxiao/18626d79f5b9f8194c87f33587289ba7 to your computer and use it in GitHub Desktop.
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 | |
test_if_network_is_reachable(){ | |
false | |
} | |
i=2 | |
max=86400 | |
while ((i<=${max})) ; do | |
test_if_network_is_reachable && break | |
sleep ${i} | |
((i=${i}*2)) | |
done | |
if ((${i}>${max})) ; then | |
while true ; do | |
test_if_network_is_reachable && break | |
sleep ${max} | |
done | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment