My boss has asked me to write a script that will detect if a certian process is running, and if it isn't to send an email to our systems group to let us know.
I wrote the script so it looks for a process ID (PID) file and if the PID is not there, to send it. That doesn't work for him.
basically, this is for a webserver. The script should read in a list of the servers that should be running, then run a ps -ef|grep -q $servername
My problem is, I have never used grep -q. I am told I can use that to figure it out.
I am very new to shell scripting
Something like this ?:
Thanks
Paul
I wrote the script so it looks for a process ID (PID) file and if the PID is not there, to send it. That doesn't work for him.
basically, this is for a webserver. The script should read in a list of the servers that should be running, then run a ps -ef|grep -q $servername
My problem is, I have never used grep -q. I am told I can use that to figure it out.
I am very new to shell scripting
Something like this ?:
Code:
for i in `cat /inet/tools/config/recycler.2live`
do
ps -ef|/usr/xpg4/bin/grep -q $i > $sucess
if success!=0
then
echo "$i not found"
fi
done
Thanks
Paul