1. 程式人生 > >CentOS7配置Tomcat8開機自動啟動

CentOS7配置Tomcat8開機自動啟動

創建 scrip ystemd shutdown 開機自啟 ice status cat service

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

CentOS7配置Tomcat8開機自動啟動