Backround process dies

From: Gurugunti, Mahesh (MGurugunti@us.nomura.com)
Date: Wed Feb 11 2004 - 12:22:08 EST


Hi,

One of our developers has written a simple shell script which monitors
(greps) a process and if this monitored process does not exist, it starts
it.

This script is run as a user as a backround job (script &) from a command
line and then the user logs out.

This script dies intermittently, and he wants to know the reasons/conditions
on which this monitoring job dies.

OS is solaris 2.8. Thanks in Advance
Mahesh

Here is the monitoring script:
###########################Begin of AsChk.sh###################
# more AsChk.sh
#!/bin/sh
USER=bbadmin
SHL=/apps/fafa/cronJob/output
HOST=`/usr/bin/hostname`
LOG_FILE=/apps/fafa/cronJob/log/${HOST}_AsChk.log
CYCLE=10

echo "===== AsChk START =====" > $LOG_FILE

while [ 1 ]
do
        sleep $CYCLE
        num=`ps -elf | grep Anal | grep ${USER} | grep -v grep | awk
'NR<2{print $4}'`
        if [ $num ]
        then
                echo "`date` : $num" >>$LOG_FILE
        else
                echo "***** Re-start AnalyticServer for $HOST by $USER" >>
$LOG_FILE
                cd ${SHL}
                AnServer.sh >> $LOG_FILE 2>> $LOG_FILE
                echo "$num" >> $LOG_FILE
                date >> $LOG_FILE
                echo "******" >> $LOG_FILE
        fi
done

echo "OUTSIDE OF WHILE LOOP" >> $LOG_FILE
# ############End of AsChk.sh#####################

And here is the AnServer.sh

##########Begin of AnServer.sh#################
# more AnServer.sh
#!/bin/sh

USER=bbadmin
HOST=`/usr/bin/hostname`
FAFA_HOME=${FAFA_HOME:-/apps/fafa}
ROOT=${FAFA_HOME}/cronJob
BIN=$FAFA_HOME/bin
SHL=$ROOT/shell
OUT=$ROOT/output
LOG=$ROOT/log

#ERR=$LOG/AnalyticServer.log
ERR=$LOG/${HOST}_AnalyticServer.log

ZXY=${FAFA_HOME}/deals
ZXY1=${FAFA_HOME}/egx
PATH=".:/usr/bin:/apps/local/bin:/usr/sbin:/usr/local/bin:$FAFA_HOME/bin:$FA
FA_HOME/cronJob/bin"

BLP_DIR_SN=/usr/market_data/bloomberg/bin/BLP_setbsn
INTEX_LIB="${FAFA_HOME}/lib/intexcmo"
ESPIEL_LIB="${FAFA_HOME}/lib/espiel"
ADC_LIB="${FAFA_HOME}/lib/adco"
BLP_LIB="/usr/market_data/bbapi/lib"

LD_LIBRARY_PATH="/usr/lib:$INTEX_LIB:$ESPIEL_LIB"
LD_LIBRARY_PATH="${ADC_LIB}:$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="/apps/local/lib:$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="${BLP_LIB}:$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="${FAFA_HOME}/lib:$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="${FAFA_HOME}/obj:$LD_LIBRARY_PATH"

export ZXY ZXY1 PATH BLP_DIR_SN LD_LIBRARY_PATH

cd $OUT

# paranoid check
# /usr/bin/ldd $BIN/AnalyticServer

# remove the old process
num=`ps -elf | grep Anal | grep ${USER} | grep -v grep | awk 'NR<2{print
$4}'`
if [ $num ]
then
echo "kill $num"
kill $num
fi

# restart the process
echo "$BIN/AnalyticServer > $ERR 2>> $ERR & "
$BIN/AnalyticServer > $ERR 2>> $ERR &

ps -elf | grep Ana

#########End of AnServer.sh##################
----- This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission. If
you receive this message in error, please delete it and all copies from your
system, destroy any hard copies and notify the sender. You must not,
directly or indirectly, use, disclose, distribute, print, or copy any part
of this message if you are not the intended recipient. Nomura Holding
America Inc., Nomura Securities International, Inc, and their respective
subsidiaries each reserve the right to monitor all e-mail communications
through its networks. Any views expressed in this message are those of the
individual sender, except where the message states otherwise and the sender
is authorized to state the views of such entity. Unless otherwise stated,
any pricing information in this message is indicative only, is subject to
change and does not constitute an offer to deal at any price quoted. Any
reference to the terms of executed transactions should be treated as
preliminary only and subject to our formal written confirmation.
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:28:02 EDT