LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   need help to write script to check the process health and automatically restart it (http://www.linuxquestions.org/questions/programming-9/need-help-to-write-script-to-check-the-process-health-and-automatically-restart-it-497316/)

dragondad 10-31-2006 03:34 PM

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.

syg00 10-31-2006 03:52 PM

maybe have a look at monit

dragondad 11-01-2006 09:13 AM

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.

Denes 11-01-2006 12:23 PM

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


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