CentOS7配置Tomcat8开机自动启动

时间:2022-03-16 16:38:05

1、创建文件

# vi /etc/systemd/system/tomcat.service

[Unit]
Description=Tomcat8540
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=oneshot
ExecStart=/usr/local/apache-tomcat-8.5.40/bin/startup.sh
ExecStop=/usr/local/apache-tomcat-8.5.40/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

2、进入目录

# cd /etc/systemd/system/

3、设置开机启动

# systemctl enable tomcat

查询当前tomcat的状态:

# systemctl status tomcat

关闭tomcat:

# systemctl stop tomcat

关闭开机自启:

# systemctl disable tomcat