1、编写*.service
文件
[Unit]
Description=esbservice
[Service]
WorkingDirectory=/opt/app/test
ExecStart=/usr/bin/java -jar /opt/app/test/XXX-3.0.jar &
User=root
Type=simple
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
2、启动程序是否正常
systemctl start esbservice.service
3、查看状态
systemctl status esbservice.service
4、自启动程序
sudo systemctl enable esbservice.service
5、重启服务器后,查看并验证程序自启是否成功
systemctl status esbservice.service
6、常用systemctl 命令
启动sshd服务:systemctl start ssh.service
停止sshd服务:systemctl stop ssh.service
查看sshd服务状态:systemctl status ssh.service
重启sshd服务:systemctl restart ssh.service
设置开机自启动:systemctl enable ssh.service
禁止开机自启动:systemctl disable ssh.service
查看所有已经启动的服务:systemctl list-units --type=service
重新加载配置文件:systemctl daemon-reload