I got a simple script if/else script working to check if a process is running and then email if it is not running anymore. My scenario is that I need to make sure the process is always running.

Instead of running the script via cron I think it is better to a have a looping script to check continually. Therefore my workflow is;

a loop to check a process is ruuning, if it is then no action, if it isn't then start the process and at that point send an email to say that it has been re-started. then go back to start of the loop.

This needs to be a csh script as it will source another csh script to if it needs to restart the process. This is the outline of what I cm up with

set DATE=`date +%d%m%y`
set TIME=`date +%H%M`
set RECIPIENT="test@test.co.uk"
set DPID = `ps -ef | grep "[u]e_21"`

while ("$DPID" != "")
     echo "ue_21 is up"
if ($DPID == "") then
     echo " test"
     echo "The ue_21 utility went down at $TIME on $DATE" and was told to restart | mail -s "The ue_21 utility went down" $RECIPIENT
sleep 10

At the moment the 'while' element doesn't appear to work. The script keeps echoing 'ue_21 is up' even if i kill the ue_21 process in a different window.

i have just tried this but it doesn't echo the text in the while script so is not working;
while ("$DPID" =~ "*")

but this doesn't even echo 'ue_21 is up'. I think I may have the operators incorrect but am just puzzled now. any help would be great if you can see where i am going wrong

9 Years
Discussion Span
Last Post by Salem
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.