bash run until success or timeout 1

bash run until success or timeout

# http://jeromebelleman.gitlab.io/posts/devops/until/
timeout 12h bash -c 'until ssh root@mynewvm; do sleep 10; done'

Here is what the above code is Doing:
1. It’s using the timeout command to run the bash command for 12 hours.
2. The bash command is running the ssh command until it succeeds.
3. The ssh command is trying to connect to the new VM.
4. If the ssh command fails, the bash command will sleep for 10 seconds and try again.
5. If the ssh command succeeds, the bash command will exit and the timeout command will exit.
6. If the timeout command exits, the script will continue.

Similar Posts