centos7 设置 tomcat 开机自启

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

posted @ 2019-08-12 22:00  每天都要进步一点点  阅读(519)  评论(0编辑  收藏  举报