這個腳本,可以滿足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 $*
運行試試
1.停止nginx
2.開啟nginx
3.重啟nginx
ok~
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對VEVB武林網的支持。
新聞熱點
疑難解答