Wait for MySQL service in loop

I have no mysql client except php mysql driver on application node, that’s why small mysql ping script have to be done.

Small sample here :

You can set execution bit by:  chmod +x mysql_ping.php

Let’s run mysql_ping in loop:

while ! `./mysql_ping.php`; do sleep 1; done && echo 'MySQL is alive'

Results when MySQL server is down:

Successful Results:


Author: GergunD

Leave a Reply