Bash- loop until a connection is successful

Date: 2015-02-16 Tags: linux, bash

I use Terminator as my terminal app, and use the “watch for activity” feature a lot. With the following command, I’d get notified as soon as the connection is opened.

while ! nc -vz localhost 3306 2> /dev/null; do sleep 1; done && echo "Available!"

Thanks for reading this post!

If you found an issue in this article, you can create an issue on Github.

If you have a comment or question, please drop me a line below!