script for failed processes

I want to write a script that log all the failed processes and start the same process.

For that I have already write a script that gives all the PID

#!/bin/ksh
pid= `ps -ef |grep "ov" |grep -v "grep"| awk '{print $2}'`
echo $pid
if [ "$? -eq 0 ];
then
echo "process is running"
else
echo "process is not running"
fi

and o/p comes ->

19 25 40 43 44 45 46 47 48 18359 1557 2015 2016 2020 2021 2022 18236 11389 10523 12950 18239 9176 18228 29786 15867 12912 18296 24251 13650 18241 29658 16027 18307 18355 15868 18240 18305 15852 18233 18242 18243 18230 22644 15853 16003 16078 18238 18297 12728 18229 29731 16083 16097 18295 18298 19476 23290 16021

now if pid 19,18242 and 23290 is not running then hw can I log these pid in another file and start the same process??

What is the string "ov" that you are searching for? Is it the username?

What exactly do you mean by failed process? A process that is not running?

yeah u r right failed process is not running process.

ov is set of process starting with ov like ovstatus,ovcheck ovbhht...

If a process named (or starting with) "ov" is NOT running, then "ps -ef | grep "ov"" will NOT show you any status precisely because it is NOT running.

You would have to use some other method to find out why it is not running and start them.

HTH, :cool:

Regards,

Praveen

I m trying following command but still not able to find whether process has stopped or not.

ps -ef | grep $process_name | grep -v "grep" | awk '{print $9}'

hw do we check that? so that I can use that check in my script.

thnx in advance