1.添加tomcat服务文件
cd /etc/init.d
vim tomcat
在tomcat中添加如下配置
#!/bin/bash # chkconfig: 2345 10 90 # description: Starts and Stops the Tomcat daemon. # /etc/init.d/tomcatd # Tomcat auto-start # Source function library. #. /etc/init.d/functions # source networking configuration. #. /etc/sysconfig/network RETVAL=0 export JAVA_HOME=/usr/local/java/ export JRE_HOME=/usr/local/java/jre export CATALINA_HOME=/home/webond/apache-tomcat-8.5.65/ export CATALINA_BASE=/home/webond/apache-tomcat-8.5.65/ start() { if [ -f $CATALINA_HOME/bin/startup.sh ]; then echo $"Starting Tomcat" $CATALINA_HOME/bin/startup.sh RETVAL=$? echo " OK" return $RETVAL fi } stop() { if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then echo $"Stopping Tomcat" $CATALINA_HOME/bin/shutdown.sh RETVAL=$? sleep 1 ps -fwwu root | grep tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9 echo " OK" # [ $RETVAL -eq 0 ] && rm -f /var/lock/... return $RETVAL fi } case "$1" in start) start ;; stop) stop ;; restart) echo $"Restaring Tomcat" $0 stop sleep 1 $0 start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 ;; esac exit $RETVAL
2.添加运行权限
chmod +x tomcat
3.加入启动列表
chkconfig --add tomcat
4.启动
systemctl start tomcat
5.查看是否启动
ps aux |grep tomcat
网上的另外一种解决方案(没成功)
在/etc/rc.d/rc.local文件最后添加下面两行脚本
export JAVA_HOME=/usr/local/java/
/home/webond/apache-tomcat-8.5.65/bin/startup.sh start
标签:bin,CATALINA,tomcat,start,Linux,自启动,HOME,RETVAL From: https://www.cnblogs.com/cy0523/p/17761581.html