语境

语境

总结:我有一台装有 Ubuntu Server 的机器,我想让它全天候运行,但它每天都会关机。我应该检查什么?我检查了几件事(见下文),但我无法修复它,而且我没有什么主意了 :)

语境

问题

我有一台新机器(Lenovo P340),我想让它不间断地运行。这是一台台式机,它永久连接到电源。更准确地说,连接到 UPS,尽管我住的地方停电不是问题。

该机器运行 Ubuntu Server 并运行 Docker 之类的程序(如 Web 服务),但几个小时后,它往往会自行“关闭”。我很想知道如何修复此问题。

我所说的关机

当我说关机时,我的意思是我无法与机器交互:没有一个docker应用程序运行,我无法ssh进入机器。如果我连接键盘并按下回车键,或者尝试使用cntrl+alt+f1/f3更改“环境”,什么也不会发生。现在,我认为它没有完全关闭,也许它进入了电源模式,因为我可以看到桌面的灯亮着。

这种情况在 docker 应用程序运行时会发生,有时甚至在我使用 ssh 或通过 samba 连接时也会发生(无需用户的实际输入,只是连接)。

我从未见过这种情况发生在我实际使用机器时(例如,当我在 ssh 上运行命令或执行操作时)。这让我认为这可能与电源管理有关。然而,也可能只是它没有同时发生。关机大约每天发生一次,时间也不一样。它可能发生在早上、下午或晚上。

我发现“摆脱”它的唯一方法是按住关闭按钮,然后再次打开它。轻轻按一下(例如“解锁”)似乎不起作用,但如果没有与机器交互的正确方法,我不确定。

故障排除

我一直在阅读、测试和收集数据。下面是我尝试过的一些方法。

假设:系统不是最新的

我目前已Ubuntu 20.04.1 LTS (GNU/Linux 5.6.0-1042-oem x86_64)定期在机器上运行更新。我已将此作为故障排除的一部分。

假设:内存超载,系统关闭

我发现最常见的原因之一是内存或 CPU 可能超载。这台机器是新的。CPU 是 Intel Core i9-10900 2.8G 10C vPro,配备 64GB RAM,而我只运行几个(约 10 个)容器。

我还一直在谈论每 15 分钟对内存使用情况进行快照并存储它们。这是top -b -o %MEM -n 1 > top.txt“停止”之前的一个例子。

top - 06:30:01 up 1 day, 11:10,  0 users,  load average: 0.05, 0.03, 0.02
Tasks: 511 total,   1 running, 508 sleeping,   0 stopped,   2 zombie
%Cpu(s):  0.6 us,  0.3 sy,  0.0 ni, 99.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  64033.5 total,  43098.9 free,   7544.9 used,  13389.7 buff/cache
MiB Swap:   8192.0 total,   8192.0 free,      0.0 used.  56011.2 avail Mem 

内存使用量约为 64GB 中的 8GB。唯一引起我注意的是 2 个僵尸任务,但除此之外,没有一个进程被大量使用。

假设:UPS 监视器指示机器关闭

服务器已连接到 UPS 服务器。我认为这可能是原因,因为有时它无法连接(但通常不会关闭)。但是,在完全禁用upsmon配置后,UPS 未连接,我也看不到其上的日志,这种情况仍然发生。

附注:就电源而言,机器仍然连接到 UPS,只是不监控其状态,而且我住在停电不常见的地区。

假设:如果不使用,机器就会进入睡眠状态

我每 30 分钟拍摄一次快照。运行快照是为了保持机器处于唤醒状态。它们使用 Jenkins 运行,Jenkins 通过 ssh 进入服务器并运行两个捕获日志和内存使用情况的命令。我希望这算作交互。一整天,我尝试每 5 分钟运行一次,不知何故,那天没有发生“关机”。不确定是巧合还是由于过程,但我正在再次测试以查看结果。

假设:GUI 有电源管理,我应该将其删除

我曾经安装过 GUI,但我已经按照评论中@guiverc 的建议将其卸载了。

我曾经参加过以下会议:

nito-server:~$ ls /usr/share/xsessions/
gnome-xorg.desktop  gnome.desktop  ubuntu.desktop

我已经关注本教程这个答案另一个答案删除 gnome 和 ubuntu 桌面。

运行此程序后,现在不再显示任何 GUI:

nito-server:~$ ls /usr/share/xsessions/

尽管如此,系统仍然会定期关闭。

假设:通过 GRUB 禁用电源接口可以解决这个问题

我在这个论坛上进行了一些研究,经常看到对 GRUB 进行更改以配置电源接口。我尝试了不同的变体并逐步增加它:

  • GRUB_CMDLINE_LINUX_DEFAULT="text"
  • GRUB_CMDLINE_LINUX_DEFAULT="text acpi=force"
  • GRUB_CMDLINE_LINUX_DEFAULT="text nomodeset acpi=force"
  • GRUB_CMDLINE_LINUX_DEFAULT="text nomodeset pci=noaer"
  • GRUB_CMDLINE_LINUX_DEFAULT="text nomodeset acpi=force pci=noaer"

我检查了正在运行的关机日志sudo journalctl -b -1 -e

Jan 18 05:33:55 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:36:26 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:36:26 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:36:26 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:36:26 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:36:39 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:36:39 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:36:39 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:36:39 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:37:39 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:37:39 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:37:39 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:37:39 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:39:05 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:39:05 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:39:05 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:39:05 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:43:31 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:43:31 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:43:31 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:43:31 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:48:59 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:48:59 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:48:59 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:48:59 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:49:07 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:49:07 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:49:07 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:49:07 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:50:02 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:50:02 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:50:02 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:50:02 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr                 
Jan 18 05:50:32 nito-server kernel: pcieport 0000:00:1b.4: AER: Corrected error received: 0000:04:00.0
Jan 18 05:50:32 nito-server kernel: nvme 0000:04:00.0: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
Jan 18 05:50:32 nito-server kernel: nvme 0000:04:00.0: AER:   device [15b7:5006] error status/mask=00000001/0000e000
Jan 18 05:50:32 nito-server kernel: nvme 0000:04:00.0: AER:    [ 0] RxErr     

检查后,最后的配置当前设置为:GRUB_CMDLINE_LINUX_DEFAULT="text pcie_aspm=off"

这似乎可以减少问题发生的频率,但问题仍然会发生。

假设:系统(BIOS)具有省电模式

我检查了 BIOS。有一个增强型省电模式。但是,(1) 这是指在已经关闭的情况下进入省电模式,而不是关闭;(2) 它被禁用了。在电源中,大多数功能都是关于自动或受控开机的。没有其他相关功能。

假设:cron 问题导致机器关闭

机器上没有直接配置 cron 任务。唯一的 cron 任务来自在 docker 容器内配置的 Jenkins。

crontab -l节目no crontab for nito

至于ll /etc/cron.hourly/演出:

total 20
drwxr-xr-x   2 root root  4096 Aug  1 00:28 ./
drwxr-xr-x 134 root root 12288 Jan 29 16:37 ../
-rw-r--r--   1 root root   102 Feb 14  2020 .placeholder

当前状态和日志

经过上述所有操作后,机器稳定了一段时间,但每 48-72 小时仍然会关机一次。以下是最新的日志记录 ( sudo journalctl -b -1 -e):

Jan 22 07:03:00 nito-server sshd[74442]: pam_unix(sshd:session): session opened for user nito by (uid=0)
Jan 22 07:03:00 nito-server systemd[1]: Created slice User Slice of UID 1000.
Jan 22 07:03:00 nito-server systemd[1]: Starting User Runtime Directory /run/user/1000...
Jan 22 07:03:00 nito-server systemd-logind[1131]: New session 61 of user nito.
Jan 22 07:03:00 nito-server systemd[1]: Finished User Runtime Directory /run/user/1000.
Jan 22 07:03:00 nito-server systemd[1]: Starting User Manager for UID 1000...
Jan 22 07:03:00 nito-server systemd[74473]: pam_unix(systemd-user:session): session opened for user nito by (uid=0)
Jan 22 07:03:00 nito-server systemd[74473]: Reached target Paths.
Jan 22 07:03:00 nito-server systemd[74473]: Reached target Timers.
Jan 22 07:03:00 nito-server systemd[74473]: Starting D-Bus User Message Bus Socket.
Jan 22 07:03:00 nito-server systemd[74473]: Listening on GnuPG network certificate management daemon.
Jan 22 07:03:00 nito-server systemd[74473]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jan 22 07:03:00 nito-server systemd[74473]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Jan 22 07:03:00 nito-server systemd[74473]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Jan 22 07:03:00 nito-server systemd[74473]: Listening on GnuPG cryptographic agent and passphrase cache.
Jan 22 07:03:00 nito-server systemd[74473]: Listening on debconf communication socket.
Jan 22 07:03:00 nito-server systemd[74473]: Listening on Sound System.
Jan 22 07:03:00 nito-server systemd[74473]: Listening on REST API socket for snapd user session agent.
Jan 22 07:03:00 nito-server systemd[74473]: Listening on D-Bus User Message Bus Socket.
Jan 22 07:03:00 nito-server systemd[74473]: Reached target Sockets.
Jan 22 07:03:00 nito-server systemd[74473]: Reached target Basic System.
Jan 22 07:03:00 nito-server systemd[1]: Started User Manager for UID 1000.
Jan 22 07:03:00 nito-server systemd[74473]: Starting Sound Service...
Jan 22 07:03:00 nito-server systemd[1]: Started Session 61 of user nito.
Jan 22 07:03:00 nito-server rtkit-daemon[8477]: Supervising 0 threads of 0 processes of 1 users.
Jan 22 07:03:00 nito-server rtkit-daemon[8477]: Supervising 0 threads of 0 processes of 1 users.
Jan 22 07:03:00 nito-server rtkit-daemon[8477]: Supervising 0 threads of 0 processes of 1 users.
Jan 22 07:03:00 nito-server rtkit-daemon[8477]: Supervising 0 threads of 0 processes of 1 users.
Jan 22 07:03:00 nito-server rtkit-daemon[8477]: Supervising 0 threads of 0 processes of 1 users.
Jan 22 07:03:00 nito-server systemd[74473]: Started D-Bus User Message Bus.
Jan 22 07:03:00 nito-server dbus-daemon[74579]: [session uid=1000 pid=74579] AppArmor D-Bus mediation is enabled
Jan 22 07:03:00 nito-server systemd[74473]: Started Sound Service.
Jan 22 07:03:00 nito-server systemd[74473]: Reached target Main User Target.
Jan 22 07:03:00 nito-server systemd[74473]: Startup finished in 122ms.
Jan 22 07:03:00 nito-server bluetoothd[1105]: Endpoint registered: sender=:1.477 path=/MediaEndpoint/A2DPSink/sbc
Jan 22 07:03:00 nito-server bluetoothd[1105]: Endpoint registered: sender=:1.477 path=/MediaEndpoint/A2DPSource/sbc
Jan 22 07:03:07 nito-server sshd[74442]: pam_unix(sshd:session): session closed for user nito
Jan 22 07:03:07 nito-server systemd[1]: session-61.scope: Succeeded.
Jan 22 07:03:07 nito-server systemd-logind[1131]: Session 61 logged out. Waiting for processes to exit.
Jan 22 07:03:07 nito-server systemd-logind[1131]: Removed session 61.
Jan 22 07:03:07 nito-server bluetoothd[1105]: Endpoint unregistered: sender=:1.477 path=/MediaEndpoint/A2DPSink/sbc
Jan 22 07:03:07 nito-server bluetoothd[1105]: Endpoint unregistered: sender=:1.477 path=/MediaEndpoint/A2DPSource/sbc
Jan 22 07:03:07 nito-server systemd[74473]: pulseaudio.service: Succeeded.
Jan 22 07:03:17 nito-server systemd[1]: Stopping User Manager for UID 1000...
Jan 22 07:03:17 nito-server systemd[74473]: Stopped target Main User Target.
Jan 22 07:03:17 nito-server systemd[74473]: Stopping D-Bus User Message Bus...
Jan 22 07:03:17 nito-server systemd[74473]: dbus.service: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Stopped D-Bus User Message Bus.
Jan 22 07:03:17 nito-server systemd[74473]: Stopped target Basic System.
Jan 22 07:03:17 nito-server systemd[74473]: Stopped target Paths.
Jan 22 07:03:17 nito-server systemd[74473]: Stopped target Sockets.
Jan 22 07:03:17 nito-server systemd[74473]: Stopped target Timers.
Jan 22 07:03:17 nito-server systemd[74473]: dbus.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed D-Bus User Message Bus Socket.
Jan 22 07:03:17 nito-server systemd[74473]: dirmngr.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed GnuPG network certificate management daemon.
Jan 22 07:03:17 nito-server systemd[74473]: gpg-agent-browser.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jan 22 07:03:17 nito-server systemd[74473]: gpg-agent-extra.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed GnuPG cryptographic agent and passphrase cache (restricted).
Jan 22 07:03:17 nito-server systemd[74473]: gpg-agent-ssh.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed GnuPG cryptographic agent (ssh-agent emulation).
Jan 22 07:03:17 nito-server systemd[74473]: gpg-agent.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed GnuPG cryptographic agent and passphrase cache.
Jan 22 07:03:17 nito-server systemd[74473]: pk-debconf-helper.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed debconf communication socket.
Jan 22 07:03:17 nito-server systemd[74473]: pulseaudio.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed Sound System.
Jan 22 07:03:17 nito-server systemd[74473]: snapd.session-agent.socket: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Closed REST API socket for snapd user session agent.
Jan 22 07:03:17 nito-server systemd[74473]: Reached target Shutdown.
Jan 22 07:03:17 nito-server systemd[74473]: systemd-exit.service: Succeeded.
Jan 22 07:03:17 nito-server systemd[74473]: Finished Exit the Session.
Jan 22 07:03:17 nito-server systemd[74473]: Reached target Exit the Session.
Jan 22 07:03:17 nito-server systemd[1]: [email protected]: Succeeded.
Jan 22 07:03:17 nito-server systemd[1]: Stopped User Manager for UID 1000.
Jan 22 07:03:17 nito-server systemd[1]: Stopping User Runtime Directory /run/user/1000...
Jan 22 07:03:17 nito-server systemd[1]: run-user-1000.mount: Succeeded.
Jan 22 07:03:17 nito-server systemd[1]: [email protected]: Succeeded.
Jan 22 07:03:17 nito-server systemd[1]: Stopped User Runtime Directory /run/user/1000.
Jan 22 07:03:17 nito-server systemd[1]: Removed slice User Slice of UID 1000.
Jan 22 07:09:52 nito-server wpa_supplicant[1135]: wlo1: WPA: Group rekeying completed with 76:ac:b9:30:c7:b5 [GTK=CCMP]
Jan 22 07:17:01 nito-server CRON[75952]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 22 07:17:01 nito-server CRON[75953]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jan 22 07:17:01 nito-server CRON[75952]: pam_unix(cron:session): session closed for user root

跑步sudo cat /var/log/syslog | grep -i "panic\|error\|hang"

Jan 29 00:00:08 nito-server systemd-resolved[1129]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Jan 29 00:00:08 nito-server systemd-resolved[1129]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Jan 29 00:00:08 nito-server systemd-resolved[1129]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Jan 29 00:00:12 nito-server systemd-resolved[1129]: message repeated 47 times: [ Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.]
Jan 29 03:01:30 nito-server networkd-dispatcher[1163]: ERROR:Unknown interface index 50 seen even after reload
Jan 29 03:01:30 nito-server networkd-dispatcher[1163]: ERROR:Unknown interface index 50 seen even after reload
Jan 29 03:01:30 nito-server kernel: [22595.674380] IPv6: ADDRCONF(NETDEV_CHANGE): vethc7eb143: link becomes ready
Jan 29 03:33:00 nito-server boltd[117319]: power: state changed: supported/on
Jan 29 03:33:05 nito-server boltd[117319]: power: state changed: supported/wait
Jan 29 03:33:05 nito-server boltd[117319]: power: state changed: supported/on
Jan 29 03:33:25 nito-server boltd[117319]: power: state changed: supported/wait
Jan 29 03:33:45 nito-server boltd[117319]: power: state changed: supported/off
Jan 29 08:31:20 nito-server boltd[117319]: power: state changed: supported/on
Jan 29 08:31:40 nito-server boltd[117319]: power: state changed: supported/wait
Jan 29 08:32:00 nito-server boltd[117319]: power: state changed: supported/off
Jan 29 08:45:13 nito-server NetworkManager[1154]: <info>  [1611881113.6500] dhcp4 (wlo1): state changed bound -> extended
Jan 29 14:12:25 nito-server systemd-resolved[1129]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Jan 29 14:12:25 nito-server systemd-resolved[1129]: message repeated 2 times: [ Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.]
Jan 29 16:36:01 nito-server systemd-resolved[1129]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Jan 29 16:36:01 nito-server systemd-resolved[1129]: message repeated 2 times: [ Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.]
Jan 29 16:36:25 nito-server NetworkManager[1154]: <info>  [1611909385.6366] manager: kernel firmware directory '/lib/firmware' changed
Jan 29 16:36:29 nito-server NetworkManager[1154]: <info>  [1611909389.8075] manager: kernel firmware directory '/lib/firmware' changed
Jan 29 16:37:04 nito-server ntpd[351772]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
Jan 29 16:37:04 nito-server ntpd[351772]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized

注意:显示的电源状态变化可能是手动变化,因为 1 月 29 日没有自动关机。

最终决定

大家好,

感谢您的提示和假设。实施所有更改并运行所有推荐的命令后,机器仍然会重新启动。好消息是它每 72 小时而不是 24 小时重新启动一次。

我决定重新安装 Ubuntu Server,看看是否能解决问题。谢谢!

答案1

我有一对 P340Tiny 系统,它们充当社区中几个非营利组织的 Web 服务器,并且没有遇到过这个特定问题。起初我以为你可能在无头模式下运行设备,因为这样做可能会触发某些系统上的 BIOS,在一段时间没有显示后强制关机。某些联想一体机上也存在同样的“功能”,如果键盘或鼠标 16 小时内没有任何活动,就会关闭机器。然而,查看用户指南中的电源功能,我没有看到任何此类功能。我还查看了我的一台 P340Tinies 的 BIOS 中的“电源”选项卡,也没有看到任何提示机器可能会自行关闭的信息:

联想 P300 系列 BIOS 设置

我可以说的是,我运行的 P340Tiny 单元没有表现出您看到的行为。它们都运行 Ubuntu Server 20.04.1,并配置为运行,直到它们被通知其他情况为止。除了偶尔重新启动外,它们一直在全天候运行。

话虽如此,你曾提到你ubuntu-desktop在机器上安装了用于 GUI 的软件包,这让我想到其中有一些东西systemd正在关闭你的机器。

检查 Sleep.Target

在桌面系统上有一项systemd-sleep服务用于各种省电模式。即使删除了 Gnome Desktop,此服务仍可能存在于您的服务器上。您可以使用以下命令检查它是否存在:

sudo systemctl status sleep.target

如果该服务存在并且正在运行,您将看到类似这样的响应:

 ● sleep.target - Sleep
    Loaded: loaded (/lib/systemd/system/sleep.target; static; vendor preset: enabled)
    Active: inactive (dead)
      Docs: man:systemd.special(7)

如果你看到这样的输出,那么你需要禁用 的省电位systemd。幸运的是,这并不太难:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

这将一步禁用睡眠、挂起、休眠和“混合睡眠”功能。您应该看到类似这样的输出:

Created symlink /etc/systemd/system/sleep.target → /dev/null
Created symlink /etc/systemd/system/suspend.target → /dev/null
Created symlink /etc/systemd/system/hibernate.target → /dev/null
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null

禁用这些功能后,您现在可以检查其完整性:

$ systemctl status sleep.target
● sleep.target
   Loaded: masked (Reason: Unit sleep.target is masked.)
   Active: inactive (dead)

请注意,该Loaded行现在显示为masked。任何尝试进入systemd睡眠状态的操作都将被忽略。

此更改立即生效,因此无需重新加载守护程序或重新启动机器。希望它能满足您的需求。

答案2

这里是在黑暗中射击。

    sudo su -
    crontab -l

还检查运行 Ubuntu 服务器的用户或应用程序的 crontab。

如果它像时钟一样有规律,那么这可能是控制行为的实用程序。

答案3

另一个方法是扫描系统日志,查找与 acpi 或 power 匹配的任何字符串

    less /var/log/syslog

它来自https://www.linuxquestions.org/questions/linux-general-1/linux-crash-log-66894/

答案4

你可以直接进入日志目录,查看之前的日志

    cd /var/logs
    ls -artl 

例如 dmesg.0 日志。您还可以解压 dmesg.1.gz、dmesg2.gz、……等文件来查看发生了什么。

将它们与 sys.log、boot.log、kern.log 结合使用。

所有以前的版本的名称中都有 .0 或 .1,或者为了保存而被压缩。

在同一目录中查找 apport.log 文件。它们同样遵循与上一个日志文件相同的编号

    apport.log.1

可能存在实际的崩溃文件

    /var/crash   

目录。

祝你狩猎顺利,mondotofu

相关内容