Shell script to check a process for every 3 min & start the process if it stops

while [ 1 -eq 1 ]
do
i=0
i=`ps -ef | grep process_to_check | grep -v grep | wc -l`
#echo $i
if [ “$i” -lt 1 ]
then
echo “starting the process”
cd /path to the process bin folder/
./start_the_process
fi
sleep 180
# runs for every 3 minute.
done

##Note: Replace process_to_check with the actual process that you need to check
##Note: “path to the process bin folder” should be replaced with the actual path of the process bin folder
##Note: “start_the_process” should be replaced with the actually command to start the process from bin folder.

Leave a Reply

Your email address will not be published. Required fields are marked *