如果nginx当掉了,我们想用shell自动拉起,可以用定时任务和ps监控实现

新建hup.sh

#!/bin/sh
ps -fe | grep “nginx” |grep -v grep

if [ $? -ne 0 ]
then
echo “starting…..”
/etc/init.d/nginx restart
else
echo “runing…..”
fi

然后在crontab中创建

*/1 * * * * /yourpath/hup.sh

保持后重启crond

Comments are closed.

Post Navigation