這個(gè)腳本,可以滿足nginx開(kāi)啟,停止和重啟的操作
#!/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 $*運(yùn)行試試
1.停止nginx

2.開(kāi)啟nginx

3.重啟nginx

ok~
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)VEVB武林網(wǎng)的支持。
新聞熱點(diǎn)
疑難解答
圖片精選