Linux 自定义service

#!/bin/bash
# source function library
# description: Thisis a ivrsocketd service.
. /etc/rc.d/init.d/functions
usage(){
  echo " usage:$0 {start|stop|restart} "
}
start(){
  /usr/local/bin/python /opt/iVR_Demo/APP_Server/APP_Server/zmqServer.py &  #后台运行
  echo -e "serice ivrsocketd Start \033[32;49;1m [OK] \033[39;49;0m"
  #echo "ivrsocketd Start                       [OK]"
}
stop(){
 kill -9 $(netstat -anp|grep 8010|awk '{printf $7}'|cut -d/ -f1)
 echo -e "serice ivrsocketd Stop  \033[32;49;1m [OK] \033[39;49;0m"
   #echo "ivrsocketd Stop                        [OK]"
}
restart(){
  stop
  start
}
#main function
case $1 in
  start)
     start
     ;;
  stop)
     stop
     ;;
  restart)
     restart
     ;;
  *)
     usage
     ;;
esac

你可能感兴趣的:(Linux—Ubuntu)