共计 475 个字符,预计需要花费 2 分钟才能阅读完成。
systemctl start test-demo-api.service //启动项目
systemctl stop test-demo-api.service //停止项目
systemctl restart test-demo-api.service //重启项目
systemctl status test-demo-api.service //查看项目状态
#服务文件内容
[Unit]
Description=服务描述
After=network.target
[Service]
WorkingDirectory=运行目录
ExecStart=java绝对路径 -jar jar包路径>log.log
ExecStop=kill $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
服务存放路径
/usr/lib/systemd/system/
重新读取服务
systemctl daemon-reload
查看启动失败原因
systemctl status test.service
systemctl status test.service -l
正文完