#!/bin/bash
LOG_FILE="/usr/slog/log_monitor_log.txt"
INSTALL_FILE="/etc/ascend_install.info"
int=1
date > $LOG_FILE
if grep '^[[:digit:]]*$' <<< "$1";then
echo "Process ID of the input parameter: $1" >> $LOG_FILE
else
echo "Invalid input parameter: $1, effective value should be Process Number" >> $LOG_FILE
exit 1
fi
PROCESS="/var/log-daemon"
DATE_FORMATE="+%F %T"
if [ $(ps -ef | grep -v grep | grep -c "${PROCESS}$") -ne 0 ];then
echo "kill $PROCESS: $1" >> $LOG_FILE
kill -31 "$1"
while(( $int<=10 ))
do
if [ $(ps -ef | grep -v grep | grep -c "${PROCESS}$") -ne 0 ];then
echo "wait to kill $PROCESS: $1" >> $LOG_FILE
sleep 1
fi
let "int++"
done
fi
echo "raise $PROCESS " >> $LOG_FILE
if [ -f "$PROCESS" ]; then
BBOX_MONITOR_SH="${HIAI_DIR}/driver/tools/bbox_daemon_monitor.sh"
if [ -f "${BBOX_MONITOR_SH}" ]; then
. "${BBOX_MONITOR_SH}"
recover_bbox_conf "${HIAI_DIR}" $LOG_FILE >> $LOG_FILE 2>&1
fi
nice -n 20 /var/log-daemon &
int=1
while(( $int<=5 ))
do
date "$DATE_FORMATE" >> $LOG_FILE
ps -ef | grep "${PROCESS}$" | grep -v grep >> $LOG_FILE
sleep 0.5
let "int++"
done
else
echo "$PROCESS is not existed" >> $LOG_FILE
fi
date "$DATE_FORMATE" >> $LOG_FILE
ps -ef | grep "${PROCESS}$" | grep -v grep >> $LOG_FILE