Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-12-2004, 12:06 PM   #1
Registered: Sep 2003
Posts: 76

Rep: Reputation: 15
script to check if the service is running

Hi all,

How to write a script to restart the mysql server when it is down.
Old 02-13-2004, 09:25 PM   #2
LQ Guru
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
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/ - 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.
Old 02-16-2004, 07:27 AM   #3
Registered: Sep 2003
Posts: 76

Original Poster
Rep: Reputation: 15
Thanks Wapcaplet. I now write a script to check if the process ID file isin /var/run.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtain ip address and check for running process via Bash Script? xconspirisist Programming 10 09-12-2008 01:18 PM
How can I check to see if a script is running? slick_willie Programming 13 03-16-2007 10:18 AM
way to check and see if a service is running nephish Linux - Software 10 02-11-2006 03:36 PM
script to check if process is dead or running rspurlock *BSD 6 04-12-2004 11:32 PM
[script] check for a running process mikshaw Linux - Software 2 01-13-2004 08:33 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration