新建一个auto-startup.sh内容如下:
cat /usr/local/apache-tomcat-7.0.70/bin/auto-startup.sh
#!/bin/sh
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
export JAVA_HOME=/usr/local/jdk1.8.0_151
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/usr/local/apache-tomcat-7.0.70
/usr/local/apache-tomcat-7.0.70/bin/catalina.sh start
添加脚本执行权限chmod +x auto-startup.sh
加入到/etc/rc.local里,实现开机启动。
cat /etc/rc.local
#!/bin/bash
/usr/local/apache-tomcat-7.0.70/bin/auto-startup.sh >> /var/log/apache_tomcat.log