원문 : http://www.ischo.net -- 조인상 //시스템 엔지니어

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

#!/bin/ksh

###########################################################
# script by ischo
# http://www.ischo.net
# chosim1@naver.com
# Shell script : Check named alive & start that if it dead.
###########################################################

TTIME=`date +%H:%M:%S`
DDATE=`date +%Y%m%d`
PROG_HOME=/home/admin/chk_named
LOGFILE=${PROG_HOME}/chk_named.log

DAEMON_NAME=/usr/sbin/named

 

echo "${DDATE} ${TTIME}  SHELL START!" >> ${LOGFILE}

 

while [ 0 ];
do


NAMED_STATUS=`ps -ef | grep ${DAEMON_NAME} | grep -v grep | wc -l`

if [ ${NAMED_STATUS} -eq 1 ];
then
        sleep 60
else
        TTIME=`date +%H:%M:%S`
        DDATE=`date +%Y%m%d`
        stopsrc -s named
        sleep 1
        startsrc -s named
        echo "${DDATE} ${TTIME}  named restarted." >> ${LOGFILE}
        echo >> ${LOGFILE}
fi


done