第一步:
vim /lib/systemd/system/tomcat.service
[Unit] Description=tomcat After=network.target [Service] Type=oneshot ExecStart=/mnt/app/tomcat-zhidu/bin/startup.sh //自已的tomcat目录 ExecStop=/mnt/app/tomcat-zhidu/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
(2).设置权限
chmod 754 tomcat.service
(3).启动关闭服务,设置开机启动
#启动服务 systemctl start tomcat.service #关闭服务 systemctl stop tomcat.service #开机启动 systemctl enable tomcat.service