[Unit]
Description=tomcat8
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment=”JAVA_HOME=/home/application/jdk1.8.0_231″
ExecStart=/usr/local/tomcat8/bin/catalina.sh start
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- 将tomcat.service放到/usr/lib/systemd/system/
- 使用systemctl命令添加开机启动:
- systemctl enable tomcat #开机启动tomcat服务
- systemctl start tomcat #启动tomcat服务器
- systemctl restart tomcat #重启tomcat服务
- systemctl stop tomcat · #停止tomcat服务
- systemctl disable tomcat #禁止开机启动