如果是yum安装的nginx,请注意更换一下/etc/init.d/nginx start这段启动代码
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH pgrep -x nginx &> /dev/null if [ $? -ne 0 ] then echo "At time:$(date) :Nginx is stop .">> /var/log/nginx_messages /etc/init.d/nginx start else exit fi