centos7用chkconfig启动编译安装得nginx脚本

vim /etc/init.d/nginx.sh

#!/bin/bash/etc/init.d

##############################################################

# File Name: nginx.sh

# Version: V1.0

# Author: oldboy

# Organization: www.oldboyedu.com

#chkconfig: 2345 21 90                #这个必须要求有得

#############################################################

[ -f /etc/init.d/functions ] && . /etc/init.d/functions

if [ $# -ne 1 ]

then

    echo "请输入(start|stop|restart)"

    exit 1

fi

start(){

    if [ "$1" = "start" ]

    then

      /application/nginx/sbin/nginx                  #编译安装得启动方式

        if [ `netstat -lntup |grep nginx |wc -l` -eq 1 ]

        then

            action "nginx is start"

        fi

    fi

}

stop(){

    if [ "$1" = "stop" ]

    then

        killall nginx                                 #编译安装得杀掉所有nginx进程

      if [ `netstat -lntup |grep nginx |wc -l` -eq 0 ]

      then 

            action "nginx is stop"

      fi

    fi

}

restart(){

    stop

    sleep 2

    start

}

mail(){

    start $1

    stop $1

    restart $1

}

mail $*

你可能感兴趣的:(centos7用chkconfig启动编译安装得nginx脚本)