我不会接受我不要的未来
哪怕是命中注定

nginx启动脚本

两个nginx的启动脚本,参考

#!/bin/bash
$nginx 启动脚本

NGINX=/usr/local/nginx/sbin/nginx
PID=/usr/local/nginx/nginx.pid
NGINX_CONF=/usr/local/nginx/nginx.conf
#source引入functions函数

. /etc/rc.d/init.d/functions

flag=0

[ -x $NGINX ] || exit 0

start()
{
  if [ -e $PID ]
  then
    echo "nginx is already runnning...."
    exit 1
  fi
  echo "start nginx ...."
  #启动守护进程
  daemon $NGINX -c $NGINX_CONF
  $flag=$?
  echo [ $flag -eq 0 ] &&touch /var/lock/subsys/nginx
  return $flag
}
stop()
{
  echo -n "Stopping nginx...."
  killproc $NGINX 
  flag=$?
  echo [ #flag = 0 ] && rm -rf /var/lock/subsys/nginx $PID
}
reload()
{
  echo -n $"Reloading ngxin: "
  #平滑启动
  killproc $nginxd -HUP
  flag=$?
  echo
}

case $1 in
start)
  start
  ;;
stop)
  stop
  ;;
restart)
  restart
  ;;
status)
  status nginx
  ;;
*)
  echo $"Usage: ngxin {start|stop|restart|reload|status|help}"
  exit 1
  ;;
esac
exit $flag
#!/bin/bash
#nginx 启动脚本

NGINX=/usr/local/nginx/sbin/nginx
PID=/usr/local/nginx/nginx.pid

. /etc/rc.d/init.d/functions

start()
{
        if [ -f $PID ]
        then
                echo "nginx已经启动"
        else
                $NGINX
                echo "nginx启动成功"
        fi
}
stop()
{
        if [ -f $PID ]
        then
                killproc $NGINX
                echo "nginx已经关闭"
        else
                echo "nginx未启动"
        fi
}
restart()
{
        if [ -f $PID ]
        then
                stop
        fi
        start
}
case $1 in
"start")
        start
        ;;
"stop")
        stop
        ;;
"restart")
        restart
        ;;
*)
        echo "请输入正确的参数start|stop|restart"
        ;;
esac

 

赞(0)
未经允许不得转载:技术搬运工 » nginx启动脚本
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

我们不生产技术 我们只是技术的搬运工