linux之lnmp启动脚本
- #!/bin/bash
- . /etc/init.d/functions
- path=/usr/local/nginx/sbin/nginx
- nginx_status(){
- status=`lsof -i:80|wc -l`
- if [ $status -gt 2 ];then
- echo "nginx is running "
- else
- echo "nginx no running"
- fi
- }
- nginx_start(){
- $path
- if [ $? -eq 0 ];then
- action "nginx start" /bin/true
- else
- action "nginx no start" /bin/false
- fi
- }
- nginx_stop(){
- $path -s stop
- if [ $? -eq 0 ];then
- action "nginx stop" /bin/true
- else
- action "nginx no stop" /bin/false
- fi
- }
- nginx_restart(){
- $path -s stop
- if [ $? -eq 0 ];then
- action "nginx stop" /bin/true
- else
- action "nginx no stop" /bin/false
- fi
- sleep 3
- $path
- if [ $? -eq 0 ];then
- action "nginx start" /bin/true
- else
- action "nginx no start" /bin/false
- fi
- }
- nginx_reload(){
- $path -s reload
- if [ $? -eq 0 ];then
- action "nginx reload" /bin/true
- else
- action "nginx no reload" /bin/false
- fi
- }
- case "$1" in
- start)
- nginx_start
- ;;
- stop)
- nginx_stop
- ;;
- restart)
- nginx_restart
- ;;
- reload)
- nginx_reload
- ;;
- status)
- nginx_status
- * )
- echo "Usage {start|stop|restart|reload|status}"
- ;;
- esac
嗨、骚年、快来消灭0回复。