Reputation: 34057
I'm working on my dedicated server running CentOS. I found out that one of my applications which starts up via a script in /etc/init.d/ requires MySQL to be running, or else it throws an error, so essentially I currently have to start it by hand.
How can I detect, in a bash script (#!/bin/sh
), whether the MySQL service has started yet? Is there some way to poll port 3306 until it is open to accept connections, and only then continue with the script? Or maybe set an order so that the script doesn't run until the mysqld script runs?
Upvotes: 1
Views: 356
Reputation: 20842
The init scripts allow you to set the order with the numbering scheme.
Example, in /etc/rc.d/rc5.d you might see:
S98first
S99second
S99second runs after S98first due to the naming.
Upvotes: 1