Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Shell script applies "four" Nginx service start-stop reload script

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Nginx service startup stop reload script known Nginx management commands are: start: / application/nginx/sbin/nginx stop: / application/nginx/sbin/nginx-s stop reload: / application/nginx/sbin/nginx-s reload Please use case script to simulate Nginx startup shutdown / etc/init.d/nginx {start | stop | restart | reload} and can be managed through chkonfig

Script:

#

# nginx startup script

# 2018-11-29

#

#! / bin/bash

# calling system functions and custom variables

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

Pidfile=/application/nginx/logs/nginx.pid

# shared functions

Publics () {

RETVAL=$?

If [$RETVAL-eq 0]; then

Action "Nginx is $1" / bin/true

Else

Actio "Nginx is $1" / bin/false

Fi

}

# launch function start

Start () {

If [- f $Pidfile]; then

Echo "Nginx is running"

Else

/ application/nginx/sbin/nginx

Publics Started

Fi

Return $RETVAL

}

# turn off function stop

Stop () {

If [!-f $Pidfile]; then

Echo "Nginx is not runing"

Else

/ application/nginx/sbin/nginx-s stop

Publics Stopped

Fi

Return $RETVAL

}

# reload the function reload

Reload () {

If [!-f $Pidfile]; then

Echo "Can't open $Pidfile, no such file directory"

Else

/ application/nginx/sbin/nginx-s reload

Publics Reload

Fi

Return $RETVAL

}

# case statement using selection

Case "$1" in

Start)

Start

RETVAL=$?

Stop)

Stop

RETVAL=$?

Reload)

Reload

RETVAL=$?

Restart)

Stop

Sleep 2

Start

RETVAL=$?

*)

Echo "USAGE:$0 {satrt | stop | restart | reload}"

Exit 1

Esac

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report