一段监控cli模式下运行php十分正常运行的shell脚本

时间:2022-09-29 12:41:18

一段监控cli模式下运行php十分正常运行的shell脚本


#!/bin/sh



LOGFILE=/var/log/$(basename $0 .sh).log
PATTERN="Admin/Cron/grubwtb"
RECOVERY="php /usr/local/nginx/html/wsserver/index.php Admin/Cron/grubwtb"


while true
do
        TIMEPOINT=$(date -d "today" +"%Y-%m-%d_%H:%M:%S")
        PROC=$(pgrep -o -f ${PATTERN})
        if [ -z "${PROC}" ]; then
                ${RECOVERY} >> $LOGFILE
                echo "[${TIMEPOINT}] ${RECOVERY}" >> $LOGFILE
        fi
sleep 5
done &