• nginx启动脚本


    [root@mail init.d]# nl /etc/init.d/nginx 
         1	#!/bin/bash
         2	# chkconfig: - 85 15
         3	# description: The Apache HTTP Server is an efficient and extensible  
         4	#	       server implementing the current HTTP standards.
         5	#
         6	# Source function library.
         7	. /etc/rc.d/init.d/functions
         8	nginx=`which nginx`
         9	case $1 in
        10		start)
        11			num=`netstat -lanput | grep nginx | wc -l`
        12			if [ $num -gt 0 ]
        13			then
        14				echo "nginx is running"	
        15			else
        16				$nginx && echo -ne "nginx is started			[ 33[31;48mok33[0m ]
    "
        17			fi
        18		;;
        19		stop)
        20			num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`
        21			if [ $num2 -gt 0 ]
        22			then
        23				$nginx -s stop > /dev/null 2>&1	
        24				num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`
        25				if [ $num2 -gt 0 ]
        26		                then
        27					pkill -9 nginx
        28				fi
        29				num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`
        30				if [ $num2 -eq 0 ]
        31				then
        32					echo -ne "nginx is stoped			[ 33[31;48mok33[0m ]
    "
        33				else
        34					echo -ne "nginx is stoped			[ 33[31;48mfaild33[0m ]
    "
        35				fi
        36			fi
        37		;;
        38		restart)
        39			num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`
        40	                if [ $num2 -gt 0 ]
        41	                then
        42	                        $nginx -s stop > /dev/null 2>&1
        43	                        num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`
        44	                        if [ $num2 -gt 0 ]
        45	                        then
        46	                                pkill -9 nginx
        47	                        fi
        48	                        num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`
        49	                        if [ $num2 -eq 0 ]
        50	                        then
        51	                                echo -ne "nginx is stoped				[ 33[31;48mok33[0m ]
    "
        52	                        else
        53	                                echo -ne "nginx is stoped				[ 33[31;48mfaild33[0m ]
    "
        54	                        fi
        55	                fi
        56			num=`netstat -lanput | grep nginx | wc -l`
        57	                if [ $num -gt 0 ]
        58	                then
        59	                        echo "nginx is running" 
        60	                else
        61	                        $nginx && echo -ne "nginx is started			[ 33[31;48mok33[0m ]
    "
        62	                fi
        63		;;
        64		status)
        65			num=`ps -ef|grep "nginx:"|grep -v grep|wc -l`
        66	                if [ $num -eq 0 ]
        67	                then
        68				echo "nginx is stoped" 
        69			else
        70				echo "nginx is runing" 
        71			fi
        72		;;
        73		*)
        74			echo "Usage: nginx {start|stop|restart|status}"
        75		;;
        76	esac
    

      

  • 相关阅读:
    HTML 特殊符号编码对照表
    C#删除字符串最后一个字符的几种方法
    c# 获取相对路径
    垂直滚动条代码
    Android微信分享功能实例+demo
    android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
    Android Camera 使用小结
    onSaveInstanceState和onRestoreInstanceState
    Android中的PopupWindow详解
    Unable to execute dex: java.nio.BufferOverflowException.解决办法
  • 原文地址:https://www.cnblogs.com/similarface/p/5469791.html
Copyright © 2020-2023  润新知