我将其放入ExecStartPre=/bin/sleep 60
18.04 Ubuntu 中的一个单元文件(服务)中
[Unit]
Description=Berkeley Open Infrastructure Network Computing Client
Documentation=man:boinc(1)
After=network-online.target
[Service]
ProtectHome=true
Type=simple
Nice=10
User=boinc
WorkingDirectory=/var/lib/boinc
ExecStartPre=/bin/sleep 60
ExecStart=/usr/bin/boinc
ExecStop=/usr/bin/boinccmd --quit
ExecReload=/usr/bin/boinccmd --read_cc_config
ExecStopPost=/bin/rm -f lockfile
IOSchedulingClass=idle
[Install]
WantedBy=multi-user.target
我还验证了 sleep 位于 /bin
jstateson@rx560:/bin$ ls -l sleep
-rwxr-xr-x 1 root root 35000 Jan 18 2018 sleep
jstateson@rx560:/bin$
但是没有效果,在syslog中发现如下错误
May 20 07:30:16 rx560 systemd[1]: boinc-client.service: Start-pre operation timed out. Terminating.
May 20 07:30:16 rx560 systemd[1]: boinc-client.service: Failed with result 'timeout'.
May 20 07:30:16 rx560 systemd[1]: Failed to start Berkeley Open Infrastructure Network Computing Client.
答案1
在您的[service]
部分中添加以下行:
TimeoutSec=infinity
更多阅读:如何更改 systemd 服务的超时值?
也就是说,您故意在启动时延迟 60 秒,也许有更好的方法......