无法获取属性:Ubuntu 16.04.3 LTS 中没有这样的接口''

无法获取属性:Ubuntu 16.04.3 LTS 中没有这样的接口''

我使用以下权限tdk-api.service在文件夹中创建了此单元文件:/etc/systemd/system-rwxr-xr-x

内容如下:

[Unit]
Description = tdk API daemon

[Service]
Type = simple
ExecStart =  /usr/local/bin/start-tdk-api.sh
ExecStop =   /usr/local/bin/stop-tdk-api.sh
ExecReload = /usr/local/bin/reload-tdk-api.sh

[Install]
WantedBy = multi-user.target

但是我在启动的时候出现错误:

root@localhost:/etc/systemd/system# sudo systemctl start tdk-api
Failed to start tdk-api.service: Unknown unit: tdk-api.service
See system logs and 'systemctl status tdk-api.service' for details.
root@localhost:/etc/systemd/system# systemctl status tdk-api.service
Failed to get properties: No such interface ''
root@localhost:/etc/systemd/system# 

我还尝试按照建议重新加载 systemd 守护进程

systemctl daemon-reload

我也尝试过:

root@localhost:/etc/systemd/system# systemctl enable tdk-api.service
Configuration file /etc/systemd/system/tdk-api.service is marked executable. Please remove executable permission bits. Proceeding anyway.
Created symlink /etc/systemd/system/multi-user.target.wants/tdk-api.service, pointing to /etc/systemd/system/tdk-api.service.
root@localhost:/etc/systemd/system# sudo systemctl start tdk-api
Failed to start tdk-api.service: Unknown unit: tdk-api.service
See system logs and 'systemctl status tdk-api.service' for details.
root@localhost:/etc/systemd/system# systemctl status tdk-api.service
Failed to get properties: No such interface ''

答案1

错误出在 start-tdk-api.sh 中。我猜要么是环境变量未设置(如 PATH),要么是你没有在你认为所在的目录中执行。

您可以在服务文件中设置环境变量或在脚本中更新 PATH 变量(可能是最简单的)。

您还可以在服务文件中设置脚本的工作目录:

[Service]
WorkingDirectory=/directory/to/run/from

相关内容