nginx linux脚本,shell脚本之nginx自动化脚本
這個腳本,可以滿足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 $*
運行試試
1.停止nginx
2.開啟nginx
3.重啟nginx
ok~
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內容請查看下面相關鏈接
總結
以上是生活随笔為你收集整理的nginx linux脚本,shell脚本之nginx自动化脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: u盘里文件没了怎么办 U盘文件丢失怎么办
- 下一篇: window10 运行linux软件,现