This script can satisfy the operations of starting, stopping and restarting nginx #!/bin/bash . /etc/init.d/functions function usage() { echo $"usage:$0 {start|stop|restart}" exit 1 } function start() { /usr/local/nginx/sbin/nginx sleep 1 if [ `netstat -antlpe | grep nginx | wc -l` -ge 0 ];then action "nginx is started." /bin/true else action "nginx is started." /bin/false fi } function stop() { killall nginx &>/dev/null sleep 1 if [ `netstat -antlpe | grep nginx | wc -l` -eq 0 ];then action "nginx is stopped." /bin/true else action "nginx is stopped." /bin/false fi } function main() { if [ $# -ne 1 ];then usage $0 fi case $1 in start) start ;; stop) stop ;; restart) stop start ;; *) usage $0 ;; esac } main $* Run the test 1. Stop nginx 2. Enable nginx 3. Restart nginx ok~ Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Detailed explanation of 6 ways of js inheritance
>>: Example of using JSX to create a Markup component style development (front-end componentization)
Table of contents 01 CMD 02 ENTRYPOINT 03 WORKDIR...
The editor recently wanted to get started with th...
Table of contents 1. Pull the image 2. Create a R...
Table of contents 1. Overview 2. Name field 3. Ve...
PSD to div css web page cutting example Step 1: F...
This article introduces and shares the responsive...
1. Background During the server development proce...
Purchase Certificate You can purchase it from Ali...
1. Command Introduction The passwd command is use...
Table of contents Preface What does yarn create d...
These introduced HTML tags do not necessarily ful...
This article example shares the specific code of ...
This article shares the specific code for the WeC...
1. Single machine environment construction# 1.1 D...
selinux ( Security-Enhanced Linux) is a Linux ker...