【Linux】- jar自启动

1、创建脚本文件

sudo vi /etc/systemd/system/leship.service

2、编写脚本

[Unit]
Description=apps
After=syslog.target
[Service]
WorkingDirectory=/home/deploy/demo_deploy
Restart=always
Type=simple
ExecStart=/usr/lib/jvm/jdk1.8.0_141/bin/java -jar /opt/apps/leship.jar
[Install]
WantedBy=multi-user.target

3、可用命令寻找JDK

whereis java

4、设置开机自启动

systemctl enable leship

5、重新写入配置

systemctl daemon-reload

6、启动服务

systemctl start leship

7、停止服务

systemctl stop leship

8、重启服务

systemctl reload leship

 

posted @ 2021-07-12 16:03  迷你胡丶  阅读(73)  评论(0编辑  收藏  举报