GrahamBright
Programmer
Hi all,
I'd like to write a simple efficent means to monitor a problematic process. I'm thinking along the following lines, but if anyone has suggestions or means to improve my script please let me know.
Thanks,
Graham.
#!/bin/ksh
#
ITSME=`basename $0` # to get the right one
LIB_DIR=${LIB_DIR:-/data/users/mmscadm/bin}
. ${LIB_DIR}/lib.sh
HOME="/opt/mmsc/scripts"
MONITOR="/data/users/mmscadm/scripts/ppe_control/ppe.pid"
log_start
touch $LOCK_FILE
rm $MONITOR
cd $HOME
#stop pped
cd $HOME
/opt/mmsc/scripts/ppe stop
sleep 10
#search for pped
PROCS=`ps -aef | grep pped|grep -v grep|cut -d " " -f 4 > $MONITOR`
if [ -s $MONITOR ] # test for file with bytes
then
PID=`cat $MONITOR`
kill $PID
fi
###########
#start pped#
cd $HOME
rm $MONITOR #remove any monitor file from old run
/opt/mmsc/scripts/ppe start
#verify pped has started correctly
PROCS=`ps -aef | grep pped|grep -v grep|cut -d " " -f 4 > $MONITOR`
if [ ! -s $MONITOR ] #test for empty file
then
echo "problem starting pped"
#email clients probabaly perl SMTP
fi
I'd like to write a simple efficent means to monitor a problematic process. I'm thinking along the following lines, but if anyone has suggestions or means to improve my script please let me know.
Thanks,
Graham.
#!/bin/ksh
#
ITSME=`basename $0` # to get the right one
LIB_DIR=${LIB_DIR:-/data/users/mmscadm/bin}
. ${LIB_DIR}/lib.sh
HOME="/opt/mmsc/scripts"
MONITOR="/data/users/mmscadm/scripts/ppe_control/ppe.pid"
log_start
touch $LOCK_FILE
rm $MONITOR
cd $HOME
#stop pped
cd $HOME
/opt/mmsc/scripts/ppe stop
sleep 10
#search for pped
PROCS=`ps -aef | grep pped|grep -v grep|cut -d " " -f 4 > $MONITOR`
if [ -s $MONITOR ] # test for file with bytes
then
PID=`cat $MONITOR`
kill $PID
fi
###########
#start pped#
cd $HOME
rm $MONITOR #remove any monitor file from old run
/opt/mmsc/scripts/ppe start
#verify pped has started correctly
PROCS=`ps -aef | grep pped|grep -v grep|cut -d " " -f 4 > $MONITOR`
if [ ! -s $MONITOR ] #test for empty file
then
echo "problem starting pped"
#email clients probabaly perl SMTP
fi