在/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