美文网首页
jar包 做成 systemctl 服务

jar包 做成 systemctl 服务

作者: 扮鬼之梦 | 来源:发表于2020-08-14 15:12 被阅读0次

进入系统服务目录

cd /etc/systemd/system/

添加文件tool.service

#表示基础信息
[Unit]
#描述
Description=tool-service
#在哪个服务之后启动
After=syslog.target network.target remote-fs.target nss-lookup.target

#表示服务信息
[Service]
Type=simple

User=root
Group=root

ExecStart=/usr/java/jdk1.8.0_131/bin/java -jar /opt/tool/tool.jar --spring.profiles.active=pro

ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID

PrivateTmp=true

#安装相关信息
[Install]
WantedBy=multi-user.target

服务操作

启动服务

systemctl start tool #或者systemctl start tool.service

停止服务

systemctl stop tool #或者systemctl stop tool.service

服务状态

systemctl status tool #或者systemctl status tool.service

开机启动

systemctl enable tool #或者systemctl enable tool.service

项目日志

journalctl -u tool #或者journalctl -u tool.service

相关文章

网友评论

      本文标题:jar包 做成 systemctl 服务

      本文链接:https://www.haomeiwen.com/subject/osigdktx.html