CentOS Linux 下Tomcat启动脚本

#!/bin/bash
#
# Init file for Apache Tomca6 server daemon
#
# chkconfig:235 80 30
#
# description:this is Apache Tomcat6 server daemon
#
# processname:tomcat6
#
# set JAVA_HOME
export JAVA_HOME=/usr/local/jdk1.6

#set Apache Tomcat6 server path
tomcat6path=/usr/local/tomcat6

start()
{
        echo -n "Start tomcat6:"
        $tomcat6path/bin/catalina.sh start
}

stop()
{
        echo -n "Stop tomcat6:"
        $tomcat6path/bin/catalina.sh stop
}

#do command
case "$1" in 
        start)
         start
         ;;

        stop)
         stop
         ;;

        restart)
         stop
         start
         ;;

        *)
         echo "Use :$0 {start|stop|restart}"
         ;;
esac

exit $RETVAL

  将此脚本保存到:/etc/init.d/tomcat6

  之后,可以将脚本添加到系统服务

  #chkconfig -add tomcat6

  启动命令:

  #/etc/init.d/tomcat6 start

 或者

  #service tomcat6 start

 本脚本同样适用于REHL 的AS5及以上

相关推荐