Suse init.d 服务启动脚本写法

#!/bin/sh
### BEGIN INIT INFO
# Provides:processA
# Required-Start:
# Should-Start: $ALL
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start processA Server
### END INIT INFO
case $1 in
start)
        echo -n "Starting processA Server: "
        perl /opt/process_server.pl&
        echo "ok"
        ;;
stop)
        echo -n "Stoping processA Server: "
        PIDLIST=`ps -ef|grep 'processA'|grep -v grep|awk '{print $2}'`;
        echo "$PIDLIST";
        while [ "${PIDLIST}" ];
         do
          PIDLIST=`ps -ef|grep 'processA'|grep -v grep|awk '{print $2}'`;
           for pid in ${PIDLIST}
             {
              kill -9 $pid;
              echo "KILL $pid";
             }
         done
        echo "ok"
        ;;
restart)
        echo -n "Restarting processA Server: "
        $0 stop
        $0 start
        echo "ok"
        ;;
*)
        # Print help
        echo "Usage: $0 {start|stop|restart}" 1>&2
        exit 1
        ;;
esac
exit 0
 

本文出自 “yiyi” 博客,转载请与作者联系!

你可能感兴趣的:(SuSE,启动脚本,init.d)