/etc/systemd/system/目录下创建tomcat.service服务,并写入下面内容

[Unit]
Description=Tomcat 9 servlet container
After=network.target

[Service]
Type=forking

User=root
Group=root

Environment="JAVA_HOME=/software/jdk/jdk1.8.0_212"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/software/tomcat/tomcat"
Environment="CATALINA_HOME=/software/tomcat/tomcat
Environment="CATALINA_PID=/software/tomcat/tomcat/bin/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/software/tomcat/tomcat/bin/startup.sh
ExecStop=/software/tomcat/tomcat/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID

[Install]
WantedBy=multi-user.target

Q.E.D.


热爱生活,热爱程序