需求:服务器有时候需要重启,手动重启比较麻烦
1、在tomcat\bin\ca中加入JAVA_HOME环境变量配置
export JAVA_HOME=/uidcloud/jdk8 export JRE_HOME=/uidcloud/jdk8/jre export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$PATH export FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS=true JAVA_OPTS="-XX:+UseParallelGC -Dlog4j2.formatMsgNoLookups=true -XX:+UseParallelOldGC -Xms64m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:hcljfl_admin_gc.log"
2、配置tomcat开机启动
vim /usr/lib/systemd/system
[unit] Description=Admin_Tomcat After= ne remo n [Service] Type=oneshot ExecStart=/uidcloud/HaiCangTomcatFolders/adminTomcat/bin ExecStop=/uidcloud/HaiCangTomcatFolders/adminTomcat/bin ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=mul
配置ExecStart,ExecStop的文件位置是tomcat相关文件的位置
3、相关服务操作
设置开机自动启动服务 systemctl enable adminTomcat.service 禁用开机自启tomcat systemctl disable 停止tomcat systemctl stop adminTomcat.service systemctl start adminTomcat.service 重启tomcat systemctl restart adminTomcat.service 查看状态tomcat systemctl status adminTomcat.service 不关闭UNIT的情况下重新载入配置文件,让配置生效,只重新加载.conf类的文件 systemctl reload adminTomcat.service