最近几天,我的 PC(运行 Ubuntu 22.04 LTS)在晚上 11 点到午夜之间一直关机,原因不明,所以我查看了系统日志。我认为这是相关部分:
Nov 6 23:02:00 Martha smartd[726]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 75 to 69
Nov 6 23:06:48 Martha gnome-shell[1300]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x3000007 specified for 0x3000005.
**Nov 6 23:07:17 Martha kernel: [32732.108304] audit: type=1107 audit(1667776037.990:87): pid=703 uid=102 auid=4294967295 ses=4294967295 subj=? msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.login1.Manager" member="PrepareForShutdown" name=":1.3" mask="receive" pid=8740 label="snap.firefox.firefox" peer_pid=734 peer_label="unconfined"
Nov 6 23:07:17 Martha kernel: [32732.108304] exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'**
Nov 6 23:07:17 Martha kernel: [32732.108327] audit: type=1420 audit(1667776037.990:88): subj_apparmor=unconfined
Nov 6 23:07:18 Martha systemd[1]: unattended-upgrades.service: Deactivated successfully.
Nov 6 23:07:18 Martha systemd[1]: Stopping Session 1 of User xxxxxxx
Nov 6 23:07:18 Martha systemd[1]: Removed slice Slice /system/getty.
Nov 6 23:07:18 Martha systemd[1]: Removed slice Slice /system/modprobe.
Nov 6 23:07:18 Martha systemd[1]: Stopped target Preparation for Logins.
Nov 6 23:07:18 Martha systemd[1]: Stopped target Graphical Interface.
Nov 6 23:07:18 Martha systemd[1]: Stopped target Multi-User System.
Nov 6 23:07:18 Martha systemd[874]: Stopped target GNOME X11 Session (session: ubuntu).
Nov 6 23:07:18 Martha systemd[874]: Stopped target GNOME Session.
....
此时 PC 无人值守,但经常处理几个很长的(按时间而言)的 bash 脚本,这些脚本当然会被终止,这意味着我从第二天开始尝试确定它们到了哪里,并在适当的点重新启动。
为什么会发生这种情况?我该如何防止?
欢迎任何想法
彼得
答案1
检查你的 /var/log/auth.log。我见过类似的问题,在某些情况下,auth.log 会包含如下行:
Jan 1 10:22:43 localhost systemd-logind[4805]: Power key pressed.
Jan 1 10:22:43 localhost systemd-logind[4805]: Powering Off...
Jan 1 10:22:43 localhost systemd-logind[4805]: System is powering down.
当然,就你的情况而言,我猜没人按电源按钮,但这可能是按钮故障或类似问题。此外,有些键盘有一个“关机”按钮,也可能有故障。你可以将其添加到 /etc/systemd/logind.conf 中以禁用电源按钮:
HandlePowerKey=ignore
希望它能对您有所帮助,或者至少为您排除另一种可能性!