LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2006, 03:34 PM   #1
dragondad
LQ Newbie
 
Registered: Aug 2005
Posts: 18

Rep: Reputation: 0
need help to write script to check the process health and automatically restart it


I write a small program, which need to constantly be watched, and check its status, if it was dead, it should be restart automatically.
Please kindly refer me to URL which teach how to write this kind of script, or service.
Thanks.
 
Old 10-31-2006, 03:52 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,384

Rep: Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190
maybe have a look at monit
 
Old 11-01-2006, 09:13 AM   #3
dragondad
LQ Newbie
 
Registered: Aug 2005
Posts: 18

Original Poster
Rep: Reputation: 0
will have back up and look for non-GUI tool or just script template

Thanks for your advice.
I am looking for a non-GUI tool or at best, just a script, may be a script template.
Thanks again.
 
Old 11-01-2006, 12:23 PM   #4
Denes
Member
 
Registered: Mar 2004
Distribution: CentOS 4.3/4.5
Posts: 72

Rep: Reputation: 15
Here is a script that will look for a process called Test every second and if it is stopped for some reason will restart it. Something like this may work for you.


#!/bin/sh
while true;
do
PROCESS='ps -A | grep Test'
if [ "$PROCESS" = "" ]
then
./Test &
fi
sleep 1
done
 
  


Reply


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
Script to check connection (and restart network if down) mac_phil Linux - Networking 15 06-21-2016 05:59 PM
Health Check / Server Completion Check Software? tells Linux - Enterprise 0 04-20-2006 11:03 AM
write a script to automatically post to a blog??? Hosiah Linux - General 11 10-14-2005 11:30 AM
How to create a bash script to automatically disown a process. jon_k Linux - Software 5 06-19-2005 05:53 AM
automatically starting process in Fedora Core 2 by using script falkesgaard Programming 1 07-29-2004 10:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:58 PM.

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