Korn Shell

Hi I am new to shell programming. I need help to write a script to monitor a process on Sun OS. If the process fails then call a oracle procedure.

i check the process if running by typing

ps -ef | grep ESP | grep -v grep
    root 29002     1  0   Mar 18 ?        7:20 /u01p/system/ESPSystemAgent/cybAgent

thanks

#!/bin/ksh

if (( $(ps -ef | grep -c [E]SP) > 0 )) ; then
   echo 'ESP is running'
else
   echo 'ESP is NOT running'
fi

How would keep this job running all the time. will the job end if the grep process is not found

or i can i run it in the backround and leave the process on machine?

the script will exit either way. This was intended as a hint at the implementation - not a complete solution.

If you want to keep cheking for the job/process, you'll either:

  1. 'cron' [man crontab] the script to be ran at predefined times
  2. write the infinite look around the 'if' with the 'sleep #Seconds' to suspend the exucution for a '# of Seconds'

thanks for the help