nginx服务器管理脚本

标题nginx服务器管理脚本

#!/bin/bash . /etc/rc.d/init.d/functionsNGX_EXC=/usr/local/nginx/sbin/nginx NGX_PID=/usr/local/nginx/logs/nginx.pidcase $1 in start) $NGX_EXC -t if [ $? -eq 0 ]; then $NGX_EXC > /dev/null 2>&1 if [ -f $NGX_PID ]; then action "Nginx启动..." true else action "Nginx启动..." false fi fi ; ; stop) [ -f $NGX_PID ] && $NGX_EXC -s stop if [ ! -f $NGX_PID ]; then action "Nginx停止..." true else action "Nginx停止..." false fi ; ; restart) [ -f $NGX_PID ] && $NGX_EXC -s stop if [ ! -f $NGX_PID ]; then action "Nginx停止..." true $NGX_EXC -t if [ $? -eq 0 ]; then $NGX_EXC > /dev/null 2>&1 if [ -f $NGX_PID ]; then action "Nginx启动..." true else action "Nginx启动..." false fi fi else action "Nginx停止..." false fi ; ; reload) $NGX_EXC -t $NGX_EXC -s reload > /dev/null 2>&1 if [ $? -eq 0 ]; then action "Nginx重新载入成功..." true else action "Nginx重新载入失败,请确认nginx启动或检查配置文件是否有误!" false fi ; ; *) echo "使用方法: nginx.sh(strat|stop|restart|reload)" esac

    推荐阅读