来源:http://coolner.blog.51cto.com/957576/688188
检测nginx服务中断并自动启动脚本:
if ps aux | grep 'nginx' | grep -v grep > /dev/null ; then echo "nginx is runnning !" else echo "nginx is down. Starting over..." /etc/init.d/nginx start fi
将此脚本保存为nginx-running.sh,在crontab加入每分钟检测一次计划即可。