Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
#!/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的脚本有点问题换了一个就行了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...