How to run a bash command until it is successful or a timeout is reached?
You can simplify things a bit by putting command right in the test and doing increments a bit differently. Otherwise the script looks fine: NEXT_WAIT_TIME=0 until (( NEXT_WAIT_TIME == 5 )) || cmd; do sleep “$(( NEXT_WAIT_TIME++ ))” done (( NEXT_WAIT_TIME < 5 ))