linux之lnmp启动脚本

7年前 (2017-06-23) gtj linux, shell 0评论 已收录 663℃
  1. #!/bin/bash  
  2.  . /etc/init.d/functions   
  3. path=/usr/local/nginx/sbin/nginx  
  4. nginx_status(){  
  5. status=`lsof -i:80|wc -l`  
  6. if [ $status -gt 2 ];then  
  7.    echo "nginx is running "   
  8.    else  
  9.    echo  "nginx no running"   
  10. fi  
  11. }  
  12.   
  13. nginx_start(){  
  14.   $path  
  15.   if [ $? -eq 0 ];then  
  16.      action "nginx start" /bin/true  
  17.   else  
  18.      action "nginx no start" /bin/false  
  19.   fi  
  20. }  
  21. nginx_stop(){  
  22.   $path -s stop  
  23.   if [ $? -eq 0 ];then  
  24.      action "nginx stop" /bin/true  
  25.   else  
  26.      action "nginx no stop" /bin/false  
  27.   fi  
  28. }  
  29. nginx_restart(){  
  30.   $path -s stop  
  31.   if [ $? -eq 0 ];then  
  32.      action "nginx stop" /bin/true  
  33.   else  
  34.      action "nginx no stop" /bin/false  
  35.   fi  
  36.   sleep 3  
  37.   $path  
  38.   if [ $? -eq 0 ];then  
  39.      action "nginx start" /bin/true  
  40.   else  
  41.      action "nginx no start" /bin/false  
  42.   fi  
  43. }  
  44. nginx_reload(){  
  45.   $path -s reload  
  46.   if [ $? -eq 0 ];then  
  47.      action "nginx reload" /bin/true  
  48.   else  
  49.      action "nginx no reload" /bin/false  
  50.   fi  
  51. }  
  52. case "$1" in  
  53. start)  
  54.      nginx_start  
  55. ;;  
  56. stop)  
  57.      nginx_stop  
  58. ;;  
  59. restart)  
  60.      nginx_restart  
  61. ;;  
  62. reload)  
  63.      nginx_reload  
  64. ;;  
  65. status)  
  66.      nginx_status  
  67.  * )  
  68.         echo "Usage {start|stop|restart|reload|status}"  
  69.         ;;  
  70.   
  71. esac  


博主

这货来去如风,什么鬼都没留下!!!

相关推荐

嗨、骚年、快来消灭0回复。

×
订阅图标按钮
Less is more!!!