How to retry a bash command until its status is ok or until a timeout is reached?
My best shot (I'm looking for something simpler):
NEXT_WAIT_TIME=0
COMMAND_STATUS=1
until [ $COMMAND_STATUS -eq 0 || $NEXT_WAIT_TIME -eq 4 ]; do
command
COMMAND_STATUS=$?
sleep $NEXT_WAIT_TIME
let NEXT_WAIT_TIME=NEXT_WAIT_TIME+1
done
retry fuction is from:
http://fahdshariff.blogspot.com/2014/02/retrying-commands-in-shell-scripts.html
if you want to retry an function in your script, you should do like this:
You can simplify things a bit by putting
command
right in the test and doing increments a bit differently. Otherwise the script looks fine:Put together some tools.
retry: https://github.com/kadwanev/retry
timeout: http://manpages.courier-mta.org/htmlman1/timeout.1.html
Then see the magic
Check exit status for ultimate pass/fail.