Problem with a script for checking the state of a process

Hello Everyone,

I have a process that should be always running. Unfortunately, this process is getting down almost every 10 minutes. I want to make a script that verify the state of this process: If the process is up, the script shouldn't do nothing and if it's down he should run it.

Can anyone help me ?

Thank you.

#!/bin/bash

## check for process running or not

ps -ef|grep -i processname|grep -v grep

if [ $? -ne 0 ]
then
echo "starting process"
###put syntax for starting the process
fi

Hello,

Here is an example for same.

 
cat check_process.ksh
 
value_process=`ps -ef | grep test_process`

if [[ -z $value_process ]]
then

mailx -s"Process test NOT found. So going to restart it now." Ravinder_Singh1@test.com
 
# starting process now.
ksh start_process.ksh
else

echo "Process is runnig fine."
fi

 
 

I have just created a test script named "check_process.ksh" in which I have tried to monitor a process named "test_process". In case this process is not running so you can call here the script which is used to start that process.

Also we can schedule this whole script named "check_process.ksh" in crontab or Maestro to schedule it to every min. So whenever your process is down it will make it up. Please try this and let us know, if we can help further on same.

Thanks,
R. Singh

I'd rather check why your process is down every 10 min. Is it a clean exit or a crash? Any error msgs or success exit state? Any log files commenting on the status?