无法运行 systemd 脚本

Jor*_*ler 6 systemd

我很难让我的 systemd 脚本在 Ubuntu 16.04 中运行。有人可以帮我检查我是否做错了什么吗?

这是脚本:

[Unit]
Description=TestProject

[Service]
ExecStart="java -Xmx2048m -Xms512m -jar /opt/project/target/test-dl-1.0.1-SNAPSHOT.jar server /opt/project/src/main/resources/config/config.yml"
Restart=always

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

我把它保存到/lib/systemd/system/,然后我运行systemctl daemon-reload然后systemctl enable myservice.service

但是,我看到的输出systemctl status myservice.service是:

Aug 17 14:59:17 ubuntu-8gb-sfo2-01 systemd[1]: [/lib/systemd/system/myservice.service:7] Executable path is not absolute, ignoring: 
Aug 17 14:59:17 ubuntu-8gb-sfo2-01 systemd[1]: myservice.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Run Code Online (Sandbox Code Playgroud)

你们看到我做的有什么不对吗?顺便说一句,我也尝试在 ExecStart 部分不使用引号,但我得到了同样的错误。

在此先感谢您的帮助。

小智 7

您开始使用的程序ExecStart必须具有完整路径。找出您的java二进制文件的位置并将其添加到 ExecStart。

前任: ExecStart=/bin/java .....