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)
Sorting query (order by) In e-commerce: We want t...
SQL Left Join, Right Join, Inner Join, and Natura...
Sometimes you need to access some static resource...
Every time I design a web page or a form, I am tr...
Some time ago, when I was working on a small func...
When using MySQL database, you often encounter su...
Method 1 Copy code The code is as follows: documen...
Web Services are concerned with application-to-ap...
1) Introduction to cache mechanism In the Linux s...
Table of contents What is a partition table Parti...
Angularjs loop object properties to achieve dynam...
Carousel animation can improve the appearance and...
<br />Hello everyone! It’s my honor to chat ...
Problem Description As we all know, when writing ...
Table of contents 1. Related binlog configuration...