操作环境:
centos7
tomcat9
1、编辑tomcat/bin/catalina.sh文件
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
2、新建tomcat.sercive文件
vim /etc/systemd/system/tomcat-console.service
Description=tomcat-console
[Unit]
Description=tomcat-console
After=syslog.target network.target remote-fs.target nss-lookup.target[Service]
Type=forking
Environment="JAVA_HOME=/usr/local/java/jdk1.8.0_112" #jdk的目录
PIDFile=/home/dangdang/soft/tomcat-console/tomcat.pid #tomcat路径
ExecStart=/home/dangdang/soft/tomcat-console/bin/startup.sh #tomcat下start.up路径
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true[Install]
WantedBy=multi-user.target
3、加载配置文件
systemctl daemon-reload
4、 测试使用
systemctl start tomcat-console #启动
systemctl stop tomcat-console #停止
systemctl restart tomcat-console #重启
systemctl enable tomcat-console #开机自启