linux下使用systemctl管理tomcat开机自启动

$touch /usr/local/tomcat-8.0.33-h1/tomcat.pid #为下面的tomcat.service服务
$vim /usr/lib/systemd/systemc/tomcat.service

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

[Service]
Type=forking
PIDFile=/usr/local/tomcat-8.0.33-h1/tomcat.pid
ExecStart=/usr/local/tomcat-8.0.33-h1/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl enable tomcat.service #自启动完成

systemctl start tomcat.service # 开始服务

你可能感兴趣的:(java,菜鸟蹒跚学java)