根据脚本配合计划任务,监控某个进程是否存在,不存在则直接拉起
#!/bin/bash
PROCESS_NAME="Application Service"
SERVER_PATH="/home/hap/event.conf"
LOG_FILE="/root/Appli_restart.log"
PROCESS_NUM=`ps -ef|grep "$SERVER_PATH"|grep -v "grep"|awk '{print $2}'|wc -l`
if [ $PROCESS_NUM -eq 0 ];then
echo "`date "+%F %T"` $PROCESS_NAME is done;">> $LOG_FILE
# runuser -l has -c "nohup /usr/lib/bin/flume agent --conf-file /home/hap/event.conf >/tmp/flume/tracklog.txt 2>&1 &"
su - hap <<EOF
nohup /usr/lib/bin/flume agent --conf-file /home/hap/event.conf >/tmp/flume/tracklog.txt 2>&1 &
EOF
fi