centOS7 tomcat 开机自启 自启动设置

时间:2024-09-23 10:06:38

1、编写配置文件

 // (1)修改tomcat.service
vim /lib/systemd/system/tomcat.service // (2)复制以下代码,注意修改tomcat路径
[Unit]
Description=tomcat
After=network.target [Service]
Type=oneshot
ExecStart=/usr/local/tomcat/apache-tomcat-9.0.16/bin/startup.sh //自已的tomcat目录
ExecStop=/usr/local/tomcat/apache-tomcat-9.0.16/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes [Install]
WantedBy=multi-user.target

2、启动服务

 systemctl start tomcat.service

3、查看服务状态

 systemctl status tomcat.service

4、设置开机启动

 systemctl enable tomcat.service

5、重启测试

 reboot

引用地址:https://blog.****.net/JEYMING/article/details/83308068