SpringBoot通过systemctl自启动

Published on with 0 views and 0 comments

/etc/systemd/system新建boot.service文件,填入如下内容。

[Unit]

Description=a
After=syslog.target mysqld.service

[Install]
WantedBy=multi-user.target

[Service]
WorkingDirectory=/home/test/boot/a
User=test
Group=test
Type=simple

# Start main service
ExecStart=/usr/local/env/java/jdk1.8.0_171/bin/java -jar /home/test/boot/a/a.jar
# EnvironmentFile=/home/test/boot/a/application.yml
ExecStop=kill $MAINPID
#Restart=always

相关命令

设置自启动:systemctl enable boot
移除自启动:systemctl disable boot
启动:systemctl startr boot
停止:systemctl stop boot
重启:systemctl restart boot
查看状态:systemctl status boot
查看日志:journalctl -f 或者 journalctl -xe

标题:SpringBoot通过systemctl自启动
作者:fyzzz
地址:https://fyzzz.cn/articles/2019/09/16/1568603807659.html