Command Line Polling

Datetime:2017-04-20 05:20:52         Topic: MySQL          Share        Original >>
Here to See The Original Article!!!

In an ideal world, we wouldn't have to poll for anything; we would always have events to trigger other functions.  This isn't an ideal world, however, so it's important to know how to poll in multiple programming languages.  I've coveredJavaScript polling (with and withoutPromises), but what about command line polling?  For example, ensuring MYSQL is up before attempting to perform more operations.

Here's the basic syntax:

# while ! (command here); do
while ! mysql -uroot; do
  sleep 1

The example above performs the mysql -uroot operation (which will fail until mysqld is up) every second.  Keep in mind the poll operation you run should be as simple as possible, just enough to know that what you want to use is available!