问题:
我有一个装有ubuntu 20.04的笔记本电脑,它被用作服务器,所以希望它永远不会休眠。
默认情况下,当盖子关闭时自动休眠。
多个站点建议使用
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
(每秒多次)
systemd-logind[514]: Suspending...
systemd-logind[514]: Unit suspend.target is masked, refusing operation.
systemd-logind[514]: Failed to execute suspend operation: Permission denied
谁能告诉我如何正确禁用挂起?
答案1:
在/etc/systemd/logind.conf
中,在底部添加以下行:
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
,并运行
systemctl restart systemd-logind
激活新设置。