自己写的 httpd 脚本

#!/bin/bash
#chkconfig: 235 99 88        ##加入 chkconfig --add 必须增加这两句
#description: this is my httpd script.
case "$1" in
start)
    if [ -e /var/run/httpd/httpd.pid  ];then
 echo "the http is running....."
else
/usr/sbin/httpd && echo -n "starting httpd :" && sleep 2 && echo -e "\033[32m \t\t\t[ ok ] \033[0m"
    fi
;;
stop)
    if [ -e /var/run/httpd/httpd.pid  ];then
   HTTPPID=$(cat /var/run/httpd/httpd.pid)
   kill $HTTPPID
  echo -n "stopping httpd :"&&sleep 2 && echo -e "\033[32m \t\t\t [ ok ] \033[0m"
else
 echo -e  "the http is \033[31m  not running.\033[0m"
     fi
;;
restart)
    if [ ! -e /var/run/httpd/httpd.pid  ];then
 echo -e  "the http is \033[31m  not running.\033[0m"
else
   HTTPPID=$(cat /var/run/httpd/httpd.pid)
   kill $HTTPPID
  echo -n "stopping httpd :"&&sleep 2 && echo -e "\033[32m \t\t\t [ ok ] \033[0m"
   /usr/sbin/httpd && echo -n "starting httpd :" && sleep 2 && echo -e "\033[32m \t\t\t[ ok ] \033[0m"
     fi
;;
status)
    if [ -e /var/run/httpd/httpd.pid  ];then
 echo "the http is running."
     else
echo "the http is not run."
     fi
;;
*)
      echo "Useage: $0 [start|stop|restart|status]"
;;
esac


你可能感兴趣的:(脚本,httpd)