除了方便重新啓動,還增加了關閉與開啓功能。
Operating System: Ubuntu Server
代碼
#!/bin/bash
function start(){
sudo service nginx start
sudo service php5-fpm start
}
function startall(){
start
sudo service mysql start
}
function stop(){
sudo service nginx stop
sudo service php5-fpm stop
}
function stopall(){
stop
sudo service mysql start
}
function restart(){
sudo service nginx restart
sudo service php5-fpm restart
}
function restartall(){
restart
sudo service mysql restart
}
## main()
case "$1" in
"start")
start
;;
"startall")
startall
;;
"stop")
stop
;;
"stopall")
stopall
;;
"restart")
restart
;;
"restartall")
restartall
;;
"configtest")
configtest
;;
*)
echo "Usage: $0 {start|stop|restart|startall|stopall|restartall}"
esac
exit 0
例如:
webserver restart //重啓nginx 和 php-fpm
來源:Zuocheng Liu‘s IT Blog LNMP啓停控制自動腳本 http://it.zuocheng.net/?p=50