如何确定为什么 systemd 服务在关机时没有停止?(停止作业正在运行)

如何确定为什么 systemd 服务在关机时没有停止?(停止作业正在运行)

最近每次我关闭或重新启动笔记本电脑时,关机都很慢,并显示以下消息:

在此处输入图片描述

A stop job is running for Session c1 of User gdm

我尝试了几个类似的问题,其中提到安装watchdog或重新配置dgm3,但它们在我看来似乎不起作用。

一些答案建议设置DefaultTimeoutStopSec,但这似乎并不能解决问题的根源,因为服务应该能够及时停止。

我的问题是如何确定为什么停止作业无法停止服务,以及如何纠正它以便计算机可以像以前一样快速关闭?


在@steeldriver 的帮助下,我能够获得关机过程的日志,但我仍然无法弄清楚如何修复它。

[  308.828908] audit: type=1400 audit(1678991943.886:84): apparmor="DENIED" operation="open" class="file" profile="snap-update-ns.firefox" name="/var/lib/" pid=7631 comm="5" requested_mask="r" denied_mask="r" f>
[  308.829327] audit: type=1400 audit(1678991943.886:85): apparmor="DENIED" operation="open" class="file" profile="snap-update-ns.firefox" name="/var/lib/" pid=7631 comm="5" requested_mask="r" denied_mask="r" f>
[  309.222571] audit: type=1400 audit(1678991944.278:86): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  309.223009] audit: type=1400 audit(1678991944.278:87): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  309.223924] audit: type=1400 audit(1678991944.278:88): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  309.224330] audit: type=1400 audit(1678991944.282:89): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  309.224340] audit: type=1400 audit(1678991944.282:90): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  309.224347] audit: type=1400 audit(1678991944.282:91): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  309.224360] audit: type=1400 audit(1678991944.282:92): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  309.224389] audit: type=1400 audit(1678991944.282:93): apparmor="DENIED" operation="open" class="file" profile="snap.firefox.firefox" name="/etc/igfx_user_feature.txt" pid=7706 comm="firefox" requested_mask=>
[  335.174797] kauditd_printk_skb: 5 callbacks suppressed
[  335.174800] audit: type=1107 audit(1678991970.224:99): pid=1311 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/org/freedesktop>
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[  388.635030] rfkill: input handler enabled
[  389.810597] ACPI BIOS Error (bug): Could not resolve symbol [\_TZ.ETMD], AE_NOT_FOUND (20220331/psargs-330)

[  389.810631] No Local Variables are initialized for Method [_OSC]

[  389.810636] Initialized Arguments for Method [_OSC]:  (4 arguments defined for method invocation)
[  389.810639]   Arg0:   00000000773fb10f <Obj>           Buffer(16) 5D A8 3B B2 B7 C8 42 35
[  389.810662]   Arg1:   0000000038c2bc32 <Obj>           Integer 0000000000000001
[  389.810673]   Arg2:   000000005d327c75 <Obj>           Integer 0000000000000002
[  389.810681]   Arg3:   00000000f7ca0178 <Obj>           Buffer(8) 00 00 00 00 00 00 00 00

[  389.810704] ACPI Error: Aborting method \_SB.IETM._OSC due to previous error (AE_NOT_FOUND) (20220331/psparse-529)
[  479.161836] r8169 0000:39:00.0 enp57s0: Link is Down
[  479.206104] wlp0s20f3: deauthenticating from 60:ce:86:8f:5c:3b by local choice (Reason: 3=DEAUTH_LEAVING)
[  479.570797] EXT4-fs (nvme0n1p2): unmounting filesystem.
[  479.845965] systemd-shutdown[1]: Syncing filesystems and block devices.
[  479.862264] systemd-shutdown[1]: Sending SIGTERM to remaining processes...
[  479.864884] systemd-journald[820]: Received SIGTERM from PID 1 (systemd-shutdow).
[  479.895325] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[  479.899820] systemd-shutdown[1]: Unmounting file systems.
[  479.900966] [8762]: Remounting '/' read-only in with options 'errors=remount-ro,stripe=32'.
[  480.202152] EXT4-fs (dm-1): re-mounted. Quota mode: none.
[  480.300538] systemd-shutdown[1]: All filesystems unmounted.
[  480.300543] systemd-shutdown[1]: Deactivating swaps.
[  480.300594] systemd-shutdown[1]: All swaps deactivated.
[  480.300596] systemd-shutdown[1]: Detaching loop devices.
[  480.302311] systemd-shutdown[1]: All loop devices detached.
[  480.302313] systemd-shutdown[1]: Stopping MD devices.
[  480.302379] systemd-shutdown[1]: All MD devices stopped.
[  480.302381] systemd-shutdown[1]: Detaching DM devices.
[  480.302661] systemd-shutdown[1]: Detaching DM /dev/dm-2 (253:2).
[  480.345817] systemd-shutdown[1]: Detaching DM /dev/dm-0 (253:0).
[  480.346518] systemd-shutdown[1]: Could not detach DM /dev/dm-0: Device or resource busy
[  480.346524] systemd-shutdown[1]: Not all DM devices detached, 2 left.
[  480.346777] systemd-shutdown[1]: Detaching DM devices.
[  480.347377] systemd-shutdown[1]: Detaching DM /dev/dm-0 (253:0).
[  480.347912] systemd-shutdown[1]: Could not detach DM /dev/dm-0: Device or resource busy
[  480.347917] systemd-shutdown[1]: Not all DM devices detached, 2 left.
[  480.347922] systemd-shutdown[1]: Cannot finalize remaining DM devices, continuing.
[  480.360045] EXT4-fs (dm-1): re-mounted. Quota mode: none.

在@RobertRiedl的帮助下,我想我能够追踪到有问题的服务session-c1.scope。以下是相关输出:

Μαρ 22 21:44:07 idefix systemd[1]: Stopping Session c1 of User gdm...
Μαρ 22 21:45:37 idefix systemd[1]: session-c1.scope: Stopping timed out. Killing.
Μαρ 22 21:45:37 idefix systemd[1]: session-c1.scope: Killing process 2431 (speech-dispatch) with signal SIGKILL.
Μαρ 22 21:45:37 idefix systemd[1]: session-c1.scope: Killing process 2440 (threaded-ml) with signal SIGKILL.
Μαρ 22 21:45:37 idefix systemd[1]: session-c1.scope: Failed with result 'timeout'.
Μαρ 22 21:45:37 idefix systemd[1]: Stopped Session c1 of User gdm.
Μαρ 22 21:45:37 idefix systemd[1]: session-c1.scope: Consumed 5.879s CPU time.

相关内容