Retry a Bash command with timeout
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 -eq 5 ] || command; do
sleep $(( NEXT_WAIT_TIME++ ))
done
[ $NEXT_WAIT_TIME -lt 5 ]
One line and shortest, and maybe the best approach:
timeout 12h bash -c 'until ssh root@mynewvm; do sleep 10; done'
Credited by http://jeromebelleman.gitlab.io/posts/devops/until/