1839233 Members
2655 Online
110137 Solutions
New Discussion

Re: Scritping Problem

 
Dewa Negara_2
New Member

Scritping Problem

Hi Folks,

I have a scripting problem here.If anyone can help me on this.I have a simple script like below :
numwork=`hrtest getconf|grep local | wc -l`
echo Number of workers is $numwork

if [ $numwork -lt 1 ]; then
echo HyperRoll is down.Send alert to DM
fi

where hrtest is a specific application command. But sometime hrtest command got hang on the system, and did not give any error. So how can I detect this problem when hrtest got hang? can I add a logic to detect it? or how can we stop the hang process? so it will give an information that hrtest is hang.

Thanks in advance.
Regards,
Dewa Negara
Dewa Negara
3 REPLIES 3
Balaji N
Honored Contributor

Re: Scritping Problem

a simple logic i use normally

save this as a separate script. use another script to run this in background. and sleep for some time. after that see if this process is still running. in that case ur has hung and just kill it.

do let me know in case u need more info.

hth
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Dewa Negara_2
New Member

Re: Scritping Problem

Balaji,

Thanks alot. Can I put like below :
#cat /tmp/script1
numwork=`hrtest getconf | grep local |wc -l`

Then on the script itself I put :
(. /tmp/script1;sleep 60) &

if [ $? -ne 0 ];then
kill -9
exit
fi

echo Number of workers is $numwork

if [ $numwork -lt 1 ]; then
echo HyperRoll is down.Send alert to DM
fi

Please confirm.
Thanks alot.
Regards,
Dewa Negara
Dewa Negara
Balaji N
Honored Contributor

Re: Scritping Problem

hi,
dont call the /tmp/script in background and run it from the same script. because there will be one instance always running. if you are not going to process further, then this is ok.

else, it should be another script.


-balaji

Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.