Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
retry bash function, copied from http://redd.it/25tgqg
retry(){
# FROM http://redd.it/25tgqg
local delay=1 n
if ! [[ $1 = *[^0-9]* ]]; then
if (($1 > 0)); then
delay=$1
fi
shift
fi
# run command
while ! "$@"; do
echo "retrying in ${delay}s" >&2
for ((n=delay; n>0; n--)); do
sleep 1 || return
done
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.