Created
October 2, 2018 09:31
-
-
Save imvaskii/d86f08a59bdc862ca78aaf275eff2736 to your computer and use it in GitHub Desktop.
A bash function to wait and retry command.
This file contains hidden or 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
# Public: Execute commands until 5 consecutive time waiting 15 seconds in each retries. | |
# | |
# Takes a single argument. | |
# | |
# $@ - Passed argument to be executed. | |
# | |
# Examples | |
# | |
# retry rake spec | |
# | |
# Returns the exit code of the last command executed in debug mode or 0 | |
function wait_n_retry() { | |
retry_count=0 | |
until [ $retry_count -ge 5 ]; do | |
return $@ && break | |
retry_count=$(($retry_count + 1)) | |
echo "Retrying command \"$@\" : count -$retry_count \n" | |
sleep 10 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment