(1)修改脚本文件
[root@localhost bin]# vim /data
添加以下内容(如图)
JAVA_HOME=/usr JRE_HOME=$JAVA_HOME/jre
(2)在/usr/lib/systemd/system/中创建文件
[root@localhost a]# vim /usr/lib/systemd/system/
粘贴下面的内容到文件
[Unit] Description=Tomcat After= ne remo n [Service] Type=oneshot ExecStart=/data/a/bin/startup.sh ExecStop=/data/a/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=mul
(3)设置开机启动
[root@localhost a]# systemctl enable Created symlink from /etc/systemd/system/mul.wants/ to /usr/lib/systemd/system/.
(4)其他命令
# 启动/停止/重启tomcat systemctl start/stop/restart # 启动tomcat