如何修复 systemd 错误:Failed to determine user credentials: No such process

问题

你有一个 systemd 服务,例如

service_unit.ini
[Unit]
Description=My Service

[Service]
ExecStart=/usr/bin/my-service
User=myuser

[Install]
WantedBy=multi-user.target

但在日志中(systemctl status my-service)你看到以下错误:

journalctl-log.txt
Jun 19 18:41:36 mycomputer (nice)[1349797]: my-service.service: Failed to determine user credentials: No such process
Jun 19 18:41:36 mycomputer systemd[1]: my-service.service: Main process exited, code=exited, status=217/USER

解决方案

原因很简单:你在 User= 指令中指定的用户在你的系统上不存在。

检查用户名是否有拼写错误,并验证它在运行服务的计算机上确实存在。


Check out similar posts by category: Systemd