Ok, I know I have asked for simple solution's in the past to more than simple problems, but here goes.
I have a simple script. Here is the basics of it.
while :
do
/usr/local/bin/selftest |grep fail
date
sleep 120
done
Now the selftest part is a compiled program written long ago by a developer no longer around. It basically tests connections to many other boxes. (IE. xcom, mq, sna, mainframe, etc) and returns either an ok or fail for each test.
While running it quite often hangs and will stay hung until I ,<ctrl>c out of it, thus my script also hangs. Now my actual script is a bit more complex in that it beeps if a fail is recieved. It works great. However if the selftest hangs I do not know untill the next time I look at the screen. That is why i have date command so I can easily see if it is current.
Now for the question. I would like to have some way to automatically tell if the selftest is hung and then kill that pid and restart my script. Not sure what avenue to look.
My best thinking is some sort of timer in my script that counts up to maybe 2 minutes then resets and if the counter does not reset then restart the script.
As always we thank you for you support.
Doug
I have a simple script. Here is the basics of it.
while :
do
/usr/local/bin/selftest |grep fail
date
sleep 120
done
Now the selftest part is a compiled program written long ago by a developer no longer around. It basically tests connections to many other boxes. (IE. xcom, mq, sna, mainframe, etc) and returns either an ok or fail for each test.
While running it quite often hangs and will stay hung until I ,<ctrl>c out of it, thus my script also hangs. Now my actual script is a bit more complex in that it beeps if a fail is recieved. It works great. However if the selftest hangs I do not know untill the next time I look at the screen. That is why i have date command so I can easily see if it is current.
Now for the question. I would like to have some way to automatically tell if the selftest is hung and then kill that pid and restart my script. Not sure what avenue to look.
My best thinking is some sort of timer in my script that counts up to maybe 2 minutes then resets and if the counter does not reset then restart the script.
As always we thank you for you support.
Doug