Linux 如何将java服务注册为Linux系统服务启动

439次阅读
没有评论

共计 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
正文完
 0
Eric chan
版权声明:本站原创文章,由 Eric chan 于2019-02-21发表,共计475字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。