CentOS安装了tomcat之后提示service tomcat does not support chkconfig

在digitalocean平台上买了一个服务器,想着自己搭建个前端项目,但是安装完Tomcat9.0之后,把tomcat加入自启的脚本中之后发现报错。

service tomcat does not support chkconfig //务tomcat不支持chkconfig

给各位看下我的脚本

#!/bin/bash  
# This is the init script for starting up the  
#  Jakarta Tomcat server  
#  
# chkconfig: 2345 80 90  ##网上说改这里,改了之后发现还是不行
# description: Starts and stops the Tomcat daemon.  
#  

# Source function library.  
. /etc/rc.d/init.d/functions  

# Get config.  
. /etc/sysconfig/network  

# Check that networking is up.  
[ "${NETWORKING}" = "no" ] && exit 0  

export JAVA_HOME=/usr/local/java/jdk1.8.0_231 #自己的jdk安装目录
tomcat_home=/home/mytomcat/apache-tomcat-9.0.35  #自己的tomcat安装目录
startup=$tomcat_home/bin/startup.sh  
shutdown=$tomcat_home/bin/shutdown.sh  

start(){  
   echo -n "Starting Tomcat service:"  
   cd $tomcat_home  
   $startup  
   echo "tomcat is succeessfully started up"  
}  

stop(){  
   echo -n "Shutting down tomcat: "  
   cd $tomcat_home  
   $shutdown  
   echo "tomcat is succeessfully shut down."  
}  

status(){  
    numproc=`ps -ef | grep catalina | grep -v "grep catalina" | wc -l`  
    if [ $numproc -gt 0 ]; then  
       echo "Tomcat is running..."  
    else  
       echo "Tomcat is stopped..."  
    fi  
}  

restart(){  
   stop  
   start  
}    
# See how we were called.  
case "$1" in  
start)  
   start  
   ;;  
stop)  
   stop  
   ;;  
status)  
   status  
   ;;  
restart)  
   restart  
   ;;  
*)  
   echo $"Usage: $0 {start|stop|status|restart}"  
   exit 1  
esac

以前没用过,也没了解过麻烦各位 提拔提拔

阅读 3.4k
2 个回答
#!/bin/bash

#chkconfig: 2345 10 90

#description: tomcat service

JAVA_HOME=/usr/local/java/jdk1.8.0_231 ##jdk 安装目录

PATH=$JAVA_HOME/bin:$PATH

CATALINA_HOME=/home/mytomcat/apache-tomcat-9.0.35 ## tomcat安装目录

export JAVA_HOME

export PATH

export CATALINA_HOME

case $1 in

start)

sh $CATALINA_HOME/bin/startup.sh

;;

stop)

sh $CATALINA_HOME/bin/shutdown.sh

;;

restart)

sh $CATALINA_HOME/bin/shutdown.sh

sh $CATALINA_HOME/bin/startup.sh

;;

esac

exit 0

可能是shll的脚本有点问题换了一个就行了。

新手上路,请多包涵

shll脚本问题,建议更换

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题