Linux系统下设置Tomcat自启动

需要将tomcat加入自启动队列中,则需要进行如下的操作:


以root用户登录系统:


cd /etc/rc.d/init.d/


vi tomcat


文件内容参考如下:

#!/bin/sh      
#      
# tomcat: Start/Stop/Restart tomcat      
#      
# chkconfig: 2345 80 20      
# description: Tomcat is a Java Servlet Container      
#      
# match these values to your environment:      
  
export CATALINA_BASE=/datas/app/tomcat6   
export CATALINA_HOME=/datas/app/tomcat  
export CATALINA_TMPDIR=/datas/app/tomcat6/temp      
export JRE_HOME=/datas/app/jdk1.6      
  
# Source function library.      
./etc/rc.d/init.d/functions      
TOMCAT=/datas/app/tomcat6  
start() {      
   echo -n "Starting Tomcat: "      
   $TOMCAT/bin/catalina.sh start      
}      
  
stop() {      
  echo -n "Stopping Tomcat: "      
  $TOMCAT/bin/catalina.sh stop      
}      
  
# See how we were called.      
case "$1" in      
    start)      
     start      
     ;;      
      
    stop)      
      stop      
      ;;      
      
    status)      
     ;;         
      
    restart)      
     stop      
     start      
     ;;      
      
    *)      
      echo "Usage: $0 {start stop restart}"      
      ;;      
  
esac      
  
exit $RETVAL   

把 tomcat 修改为可运行的文件,命令参考如下:


chmod a+x tomcat


使用chkconfig命令把 tomcat 命令加入到系统启动队列中: chkconfig --add tomcat


查看apachectl的状态: chkconfig --list tomcat

 

如果2-5都为启动说明正常。然后chkconfig tomcat on设置开机启动

好了,全部完成!

posted @ 2016-06-01 19:03  tantanba  阅读(263)  评论(0编辑  收藏  举报