当启用systemd
用户单元时,例如redshift.service
,此服务在启动时无法启动并出现错误redshift.service: Start request repeated too quickly.
$ systemctl --user enable redshift.service
Created symlink /home/pavel/.config/systemd/user/default.target.wants/redshift.service → /usr/lib/systemd/user/redshift.service.
当我通过手动启动它时systemctl --user start redshift.service
,redshift 启动并运行:
$ systemctl --user status redshift.service
● redshift.service - Redshift display colour temperature adjustment
Loaded: loaded (/usr/lib/systemd/user/redshift.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2017-07-18 17:12:31 +05; 13min ago
Docs: http://jonls.dk/redshift/
Main PID: 23289 (redshift)
CGroup: /user.slice/user-1000.slice/[email protected]/redshift.service
└─23289 /usr/bin/redshift
但是,redshift.service
无法在系统启动时启动-出现以下错误:
$ journalctl --user-unit redshift.service
-- Logs begin at Tue 2017-07-18 15:15:04 +05, end at Tue 2017-07-18 16:42:26 +05. --
июл 18 15:15:27 ubuntu-pc systemd[1603]: Started Redshift display colour temperature adjustment.
июл 18 15:15:27 ubuntu-pc redshift[1620]: `RANDR Query Version' returned error -1
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Main process exited, code=exited, status=1/FAILURE
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Unit entered failed state.
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Failed with result 'exit-code'.
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Service hold-off time over, scheduling restart.
июл 18 15:15:27 ubuntu-pc systemd[1603]: Stopped Redshift display colour temperature adjustment.
июл 18 15:15:27 ubuntu-pc systemd[1603]: Started Redshift display colour temperature adjustment.
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Main process exited, code=exited, status=1/FAILURE
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Unit entered failed state.
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Failed with result 'exit-code'.
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Service hold-off time over, scheduling restart.
июл 18 15:15:27 ubuntu-pc systemd[1603]: Stopped Redshift display colour temperature adjustment.
июл 18 15:15:27 ubuntu-pc systemd[1603]: Started Redshift display colour temperature adjustment.
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Main process exited, code=exited, status=1/FAILURE
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Unit entered failed state.
июл 18 15:15:27 ubuntu-pc systemd[1603]: redshift.service: Failed with result 'exit-code'.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Service hold-off time over, scheduling restart.
июл 18 15:15:28 ubuntu-pc systemd[1603]: Stopped Redshift display colour temperature adjustment.
июл 18 15:15:28 ubuntu-pc systemd[1603]: Started Redshift display colour temperature adjustment.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Main process exited, code=exited, status=1/FAILURE
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Unit entered failed state.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Failed with result 'exit-code'.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Service hold-off time over, scheduling restart.
июл 18 15:15:28 ubuntu-pc systemd[1603]: Stopped Redshift display colour temperature adjustment.
июл 18 15:15:28 ubuntu-pc systemd[1603]: Started Redshift display colour temperature adjustment.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Main process exited, code=exited, status=1/FAILURE
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Unit entered failed state.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Failed with result 'exit-code'.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Service hold-off time over, scheduling restart.
июл 18 15:15:28 ubuntu-pc systemd[1603]: Stopped Redshift display colour temperature adjustment.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Start request repeated too quickly.
июл 18 15:15:28 ubuntu-pc systemd[1603]: Failed to start Redshift display colour temperature adjustment.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Unit entered failed state.
июл 18 15:15:28 ubuntu-pc systemd[1603]: redshift.service: Failed with result 'exit-code'.
redshift.service
文件包含:
$ cat /usr/lib/systemd/user/redshift.service
[Unit]
Description=Redshift display colour temperature adjustment
Documentation=http://jonls.dk/redshift/
After=display-manager.service
[Service]
ExecStart=/usr/bin/redshift
Restart=always
[Install]
WantedBy=default.target
Ubuntu 17.04,systemd 232
$ systemd --version
systemd 232
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN
$ uname -a
Linux ubuntu-pc 4.10.0-24-generic #28-Ubuntu SMP Wed Jun 14 08:14:34 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 17.04
Release: 17.04
Codename: zesty
有人可以帮忙吗,有办法解决这个问题吗?
答案1
这是一个已知的限制。您的单元文件必须位于与根文件系统相同的分区中。请参阅man systemctl
:
link PATH...
Link a unit file that is not in the unit file search paths into the
unit file search path. This command expects an absolute path to a
unit file. The effect of this may be undone with disable. The
effect of this command is that a unit file is made available for
commands such as start, even though it is not installed directly in
the unit search path. The file system where the linked unit files
are located must be accessible when systemd is started (e.g.
anything underneath /home or /var is not allowed, unless those
directories are located on the root file system).