CentOS7配置Tomcat开机自动启动和服务

创建文件

# 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

进入目录

# cd /etc/systemd/system/

设置开机启动

# systemctl enable tomcat

查询当前tomcat的状态:

# systemctl status tomcat

关闭tomcat:

# systemctl stop tomcat

关闭开机自启:

# systemctl disable tomcat

你可能感兴趣的:(CentOS7配置Tomcat开机自动启动和服务)