#!/bin/bash
process='nginx php-fpm'
bin="/etc/init.d"
log="/data/logs/check_process.log"
data=$(date +"%Y-%m-%d %H:%M:%S")
for i in $process
do
#echo $i
exists=`ps -ef|grep "$i"|grep -v grep|wc -l`
if [ "$exists" -eq "0" ]; then
${bin}/${i} restart
if [ "$?" -eq "0" ]; then
echo "${data} : ${i} ------------------restart sucesses------------------" >> $log
else
echo "${data} : ${i} ***-------------------------------------------------------------restart failed***" >> $log
fi
else
echo "${data} : ${i} already running" >> $log
fi
done
---------------------
转载自:https://blog.csdn.net/wangshui898/article/details/80236458
进程自动重启 以nginx 和 php-fpm为例
猜你喜欢
转载自blog.csdn.net/qq125293177/article/details/85128853
今日推荐
周排行