I have written a service, which should start only after MySQL service starts as the instance boots.
Operating System: Centos 6.10.
How to make the service wait until MySQL service starts completely on boot?
I tried creating startup service in /etc/init.d startup service script :
# chkconfig: 345 99 01
# description: service startup script
### BEGIN INIT INFO
# Required-Start: mysqld
### END INIT INFO
cd /path_of_server
./start.sh
The issue I am facing is, my service executes before MySQL service starts completely.
This might help you:
systemctl has an is-active subcommand for this:
systemctl is-active --quiet service
will exit with status zero if service is active, non-zero otherwise, making it ideal for scripts:
systemctl is-active --quiet service && echo Service is running
If you omit --quiet it will also output the current status to its standard output.
Make an infinite loop in the shell script and check whether MySQL is running or not using above command inside a loop.
As soon as you find the MySQL running start your service and exit from a loop or script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With