Nginx Startup Script

Source: Internet
Author: User

#! /Bin/bash

Nginx =/usr/local/nginx/sbin/nginx

PID =/usr/local/nginx/logs/nginx. PID


# Fun

Start (){

Pstree-p | grep nginx>/dev/null 2> & 1

If [-F $ pid] & [$? -EQ 0]

Then

Echo "warnning: nginx already running"

Else

If [-F $ pid]; then

Rm-RF $ PID

Fi

$ Nginx

# Stdin OK

If [$? -EQ 0]; then

Echo-e "nginx start \ t [\ 033 [32 m OK \ 033 [0 m]"

Else

Echo-e "nginx start \ t [\ 033 [31 m fail \ 033 [0 m]"

Fi

Fi

}



Stop (){

Pstree-p | grep nginx>/dev/null 2> & 1

If [-F $ pid] & [$? -EQ 0]

Then

Killall-s quit nginx

# Check

If [$? -EQ 0]; then

Echo-e "nginx stop \ t [\ 033 [32 m OK \ 033 [0 m]"

Fi

Else

Rm-RF/usr/local/nginx/logs/nginx. PID>/dev/null 2> & 1

Echo-e "nginx stop \ t [\ 033 [31 m fail \ 033 [0 m]"

Fi

}



Restart (){

Stop; sleep 1; Start

}



Reload (){

If [-F $ pid] & [$? -EQ 0]

Then

Killall-s hup $ nginx

# Reload check

If [$? -EQ 0]; then

Echo-e "nginx reload \ t [\ 033 [32 m OK \ 033 [0 m]"

Fi

Else

Echo "warnning: nginx stop, please start nginx"

Fi

}



Status (){

Elinks http: // localhost-dump>/dev/null 2> & 1


If [$? -EQ 0]; then

Echo "nginx running ..."

Else

Echo "nging stop"

Fi

}


# Main

Case $1 in

Start) Start ;;

Stop) Stop ;;

Restart) restart ;;

Reload) Reload ;;

Status) status ;;

*) Echo "Usage: avge is START | stop | restart | reload | status ";;

Esac


This article is from the "frequently used documentation" blog, please be sure to keep this source http://yujianglei.blog.51cto.com/7215578/1561565

Nginx Startup Script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.