Skip to content

Instantly share code, notes, and snippets.

@isjerryxiao
Last active July 9, 2017 10:09
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 isjerryxiao/18626d79f5b9f8194c87f33587289ba7 to your computer and use it in GitHub Desktop.
Save isjerryxiao/18626d79f5b9f8194c87f33587289ba7 to your computer and use it in GitHub Desktop.
Exponential backoff
#!/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