Last active
October 10, 2017 08:33
-
-
Save shiroyasha/024ec9fe74a64533bc63f9287c2d97b0 to your computer and use it in GitHub Desktop.
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
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