Skip to content

Instantly share code, notes, and snippets.

@spladug
Forked from fungusakafungus/gist:1026804
Created March 5, 2013 02:11
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 spladug/5087447 to your computer and use it in GitHub Desktop.
Save spladug/5087447 to your computer and use it in GitHub Desktop.
function retry {
local retry_max=$1
shift
local count=$retry_max
while [ $count -gt 0 ]; do
"$@" && break
count=$(($count - 1))
sleep 1
done
[ $count -eq 0 ] && {
echo "Retry failed [$retry_max]: $@" >&2
return 1
}
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment