首先systemd服务文件
/etc/systemd/system/test.service(文件简化处理了)
[Unit]
Description=test
After=network.target
[Service]
ExecStart=/opt/test/bin/test_start.sh
[Install]
WantedBy=multi-user.target
其中启动命令ExecStart指向的是一个sh启动脚本,
脚本内就是简单的jar包启动命令 java -jar test.jar
然后执行启动命令:
sudo systemctl restart test.service
查看日志发现
3月 06 17:33:29 localhost.localdomain test.sh[8322]: /opt/cloud/bin/test_start.sh:行2: java: 未找到命令
3月 06 17:33:29 localhost.localdomain systemd[1]: test.service: Main process exited,