Skip to content

Instantly share code, notes, and snippets.

@shiroyasha shiroyasha/retry.sh
Last active Oct 10, 2017

Embed
What would you like to do?
function retry {
local n=1
local max=5
local delay=15
while true; do
"$@" && break || {
if [[ $n -lt $max ]]; then
((n++))
echo "Command failed. Attempt $n/$max:"
sleep $delay;
else
echo "The command has failed after $n attempts."
false
fi
}
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.