我有一个 Ubuntu 服务器实例,它会不时进入睡眠模式(平均每两个月一次)。通过查看 syslog 文件,我发现是 networkManager 请求让主机进入睡眠状态。
以下是日志条目:
Aug 24 11:33:28 home dbus-daemon[1108]: [session uid=108 pid=1108] Activating service name='org.freedesktop.Notifications' requested by ':1.12' (uid=108 pid=1145 comm="/usr/lib/unity-settings-daemon/unity-settings-daem" label="unconfined")
Aug 24 11:33:29 home org.freedesktop.Notifications[1108]: Unable to init server: Impossible de se connecter : Connexion refusée
Aug 24 11:33:29 home notify-osd[19718]: cannot open display:
Aug 24 11:33:29 home dbus-daemon[1108]: [session uid=108 pid=1108] Activated service 'org.freedesktop.Notifications' failed: Process org.freedesktop.Notifications exited with status 1
Aug 24 11:33:29 home dbus-daemon[1108]: [session uid=108 pid=1108] Activating service name='org.freedesktop.Notifications' requested by ':1.12' (uid=108 pid=1145 comm="/usr/lib/unity-settings-daemon/unity-settings-daem" label="unconfined")
Aug 24 11:33:29 home NetworkManager[880]: <info> [1598261609.2373] manager: sleep: sleep requested (sleeping: no enabled: yes)
Aug 24 11:33:29 home NetworkManager[880]: <info> [1598261609.2382] manager: NetworkManager state is now ASLEEP
Aug 24 11:33:29 home whoopsie[21081]: [11:33:29] offline
Aug 24 11:33:29 home org.freedesktop.Notifications[1108]: Unable to init server: Impossible de se connecter : Connexion refusée
Aug 24 11:33:29 home notify-osd[19725]: cannot open display:
Aug 24 11:33:29 home dbus-daemon[1108]: [session uid=108 pid=1108] Activated service 'org.freedesktop.Notifications' failed: Process org.freedesktop.Notifications exited with status 1
Aug 24 11:33:29 home systemd[1]: Reached target Sleep.
Aug 24 11:33:29 home systemd[1]: Starting Suspend...
Aug 24 11:33:29 home kernel: [3268843.256198] PM: suspend entry (deep)
Aug 24 11:33:29 home systemd-sleep[19726]: Suspending system...
这是什么原因造成的?这是网络问题还是配置问题造成的?
编辑:以下是评论中要求的一些附加信息
$ sudo systemctl status suspend.target
[sudo] Mot de passe de meessen :
● suspend.target - Suspend
Loaded: loaded (/lib/systemd/system/suspend.target; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
答案1
以下是对我有用的方法:
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
此命令禁用服务器上的睡眠模式。
如果我们想再次启用它:
systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target