linux下将tomcat加入服务

#!/bin/sh

#chkconfig: 2345 10 90

# description: Starts and Stops the Tomcat daemon.

##############################################

#Startup script for Tomcat on Linux

JAVA_HOME=/usr/java/jdk1.7.0_79                  #JDK安装目录 CATALINA_HOME=/app/tomcat7pay           #tomcat安装目录

export JAVA_HOME

export CATALINA_HOME

###############################################

start_tomcat=/app/tomcat7pay/bin/startup.sh              #tomcat启动文件 stop_tomcat=/app/tomcat7pay/bin/shutdown.sh                  #tomcat关闭文件

start() {                                                                     

    echo -n "Starting tomcat: "        

     ${start_tomcat}        

    echo "tomcat start ok."

    }

stop() {        

     echo -n "Shutting down tomcat: "        

    ${stop_tomcat}        

    echo "tomcat stop ok."

    }

# See how we were called                                                   

  case "$1" in  

   start)       

      start        

      ;;  

   stop)        

     stop        

      ;;  

      restart)        

    stop        

    sleep 10        

    start        

    ;;  

  *)        

       echo "Usage: $0 {start|stop|restart}"

esac

exit 0

 

 

 

 

 

上面的文字修改后改名为tomcat7xxx,放入/etc/rc.d/init.d
授权:命令行进入:/etc/rc.d/init.d
执行命令:chmod 755 tomcat7xxx
使用chkconfig命令把 tomcat7xxx 命令加入到系统启动队列中:chkconfig --add tomcatxxx

posted @ 2016-03-16 11:02  收点资料买框架  阅读(153)  评论(0编辑  收藏  举报