2008-07-01

 

Monitoring when a process dies - near real time

I recently had a question on c.o.l.s about real time process monitoring. Although there is still refinement required, I have my fav solution here:

#!/bin/bash

PROG=$1
N=0
while :
do
if [ ! -x $PROG ]; then
echo "$PROG is not executable" >&2
exit 1
fi
if [ $N -lt $SECONDS ]; then
N=$SECONDS
elif [ $(($N - 5)) -ge $SECONDS ]; then
echo "$PROG restarting too frequently -- sleeping" >&2
sleep 10
fi
N=$(($N+1))
$PROG
done

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?