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

Nginx Automation script for shell script

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

Share

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

This script can satisfy the operation of starting, stopping and restarting nginx.

#! / bin/bash. / etc/init.d/functionsfunction 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 $*

Try to run

1. Stop nginx

two。 Turn on nginx

3. Restart nginx

Ok~

Summary

The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.

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