Do task until it succeeds
A story
I was working on my vm and needed to reboot it. In order to ssh back into the machine, I would have to wait for it to come back online and start up ssh. Instead of manually polling myself, I whipped up this little one-liner:
while ! ssh centos7-01a; do true; done
So it failed silently at first, and then started showing ssh_exchange_identification: Connection closed by remote host. Then when OpenSSH was finally ready for me, my kerberos authentication proceeded normally and I was in. Upon closing my session, the while loop concluded and returned me to my shell. I came up with this little snippet on a whim, and it actually helped me out and was not obtrusive and did not fail in any way.
Comments