1、 新建Systemed配置文件 参考以下配置文件样例
sudo vim /lib/systemd/system/tomcat.service
2、 重新加载Systemed配置信息
sudo systemctl daemon-reload
3、 打开自动启动Tomcat
sudo systemctl enable tomcat.service
4、 启动Tomcat
sudo systemctl start tomcat.service
5、 停止Tomcat
sudo systemctl stop tomcat.service
6、 查看Tomcat运行情况
sudo systemctl status tomcat.service Systemed
配置文件样例【需要修改路径地址】
[Unit]
Description=Tomcat
After=syslog.target network.target mysqld.service
[Service]
Type=forking
WorkingDirectory=/usr/local/tomcat/
Environment="JAVA_HOME=/usr/local/jdk/default"
Environment="CATALINA_PID=/usr/local/tomcat/run/tomcat.pid"
Environment="CATALINA_BASE=/usr/local/tomcat"
Environment="CATALINA_HOME=/usr/local/tomcat"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
#RestartSec=10
#Restart=always
[Install]
WantedBy=multi-user.target
标签:Systemed,Tomcat,tomcat,sudo,service,usr,Ubuntu,local From: https://www.cnblogs.com/daijingjing/p/18205673