我有一个简单的 systemd 服务和计时器,~/.config/systemd/user
用于构建我最喜欢的程序的夜间图像:
# ~/.config/systemd/user/kicad-build.service
[Unit]
Description=KiCAD nightly builder
[Service]
Type=simple
StandardOutput=null
ExecStart=/bin/bash /home/jan/kicad-nightly-builder/build.sh
# ~/.config/systemd/user/kicad-build.timer
[Unit]
Description=KiCAD nightly build timer
[Timer]
OnCalendar=daily
Persistent=true
RandomizedDelaySec=7200
[Install]
WantedBy=timers.target
现在我想禁用计时器,因为我不再需要夜间构建:
[jan@memory-alpha user]$ systemctl --user stop kicad-build.timer
[jan@memory-alpha user]$ systemctl --user disable kicad-build.timer
Failed to disable unit: Unknown method DisableUnitFilesWithFlagsAndInstallInfo or interface org.freedesktop.systemd1.Manager.
这里发生了什么?为什么systemctl
找不到合适的方法来禁用该单元?计时器仍然启用:
[jan@memory-alpha user]$ systemctl --user status kicad-build.timer
○ kicad-build.timer - KiCAD nightly build timer
Loaded: loaded (/home/jan/.config/systemd/user/kicad-build.timer; enabled; preset: enabled)
Active: inactive (dead) since Sat 2023-03-04 09:54:42 CET; 11min ago
Duration: 1month 2w 5d 13h 3min 15.725s
Trigger: n/a
Triggers: ● kicad-build.service
Jan 13 10:21:26 memory-alpha systemd[901]: Started KiCAD nightly build timer.
Mar 04 09:54:42 memory-alpha systemd[901]: Stopped KiCAD nightly build timer.
进一步测试:
[jan@memory-alpha user]$ gdbus introspect --system --dest org.freedesktop.systemd1 --object-path /org/freedesktop/systemd1 | grep DisableUnit
DisableUnitFiles(in as files,
DisableUnitFilesWithFlags(in as files,
DisableUnitFilesWithFlagsAndInstallInfo(in as files,
[jan@memory-alpha user]$ gdbus introspect --session --dest org.freedesktop.systemd1 --object-path /org/freedesktop/systemd1 | grep DisableUnit
DisableUnitFiles(in as files,
DisableUnitFilesWithFlags(in as files,
显然我的系统会话有适当的方法,尽管我的用户会话没有。不幸的是我对 D-Bus 的了解不够,无法进一步调试这个问题,有什么想法吗?
[jan@memory-alpha user]$ uname -a
Linux memory-alpha 6.1.4-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 07 Jan 2023 15:10:07 +0000 x86_64 GNU/Linux
[jan@memory-alpha user]$ systemctl --version
systemd 253 (253-1-arch)
+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified
答案1
您的系统正在运行 systemd 版本,该版本与 systemctl 版本相比太旧。 (此 D-Bus 方法是在 systemd v253 中添加的。)
用于systemctl [--user] daemon-reexec
升级正在运行的 systemd 版本。