centos设置tomcat开机启动

1.编辑开机启动脚本

vi /etc/init.d/tomcat8

#!/bin/bash  
# tomcat8:start|stop|restart  
# chkconfig: 345 90 10  
# description: tomcat8  
# processname: tomcat8   
  
export JAVA_HOME=/usr/local/programs/jdk1.8  
TOMCAT_HOME=/usr/local/programs/tomcat8  
case "$1" in  
'start')  
   echo -n $"Starting tomcat!  "  
        $TOMCAT_HOME/bin/startup.sh  
   ;;  
'stop')  
   echo -n $"Stopping tomcat!  "  
         $TOMCAT_HOME/bin/shutdown.sh  
   ;;  
'restart')  
   $0 stop  
   $0 start  
   ;;  
*)  
   echo "Usage: $0 [start|stop|restart]"  
   exit 1  
esac  
exit 0  

修改/etc/init.d/tomcat8启动服务文件权限  
chmod 755 /etc/init.d/tomcat8


2. 执行chkconfig命令,设置启动

#cd /etc/init.d

#chkconfig --add tomcat8

查看 tomcat8的状态

[root@TestServer-DFJR init.d]# chkconfig --list tomcat8
tomcat8 0:off 1:off 2:off 3:on 4:on 5:on 6:off

 

posted @ 2018-01-21 10:15  猪脚踏浪  阅读(803)  评论(0编辑  收藏  举报