LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   script to check if the service is running (https://www.linuxquestions.org/questions/linux-newbie-8/script-to-check-if-the-service-is-running-145291/)

eyt 02-12-2004 12:06 PM

script to check if the service is running
 
Hi all,

How to write a script to restart the mysql server when it is down.

wapcaplet 02-13-2004 09:25 PM

One way is to have your script run "/etc/init.d/mysql status" and look for either "stopped" or "started" in the output (using grep). You may also be able to find out whether it's running by whether or not there's a process ID file in /var/run (should be called /var/run/mysql.pid) - if it's there, it's probably running.

/etc/init.d may or may not exist depending on your distro... sometimes there are different directories for each runlevel, so poke around until you find it.

eyt 02-16-2004 07:27 AM

Thanks Wapcaplet. I now write a script to check if the process ID file isin /var/run.


All times are GMT -5. The time now is 09:07 AM.