我有一台已经安装了ubuntu20.04的笔记本电脑,它被用作服务器。因此,我希望它永远不要暂停。
默认情况下,当盖子关闭时它会自动挂起。
因为我只能通过ssh访问它(而且也没有安装X),所以我需要通过CLI禁用它。
多个站点建议使用
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
这确实会阻止笔记本电脑在关闭盖子时挂起,但是导致systemd-logind消耗100%的cpu并连续记录以下内容:(每秒多次)
systemd-logind[514]: Suspending...
systemd-logind[514]: Unit suspend.target is masked, refusing operation.
systemd-logind[514]: Failed to execute suspend operation: Permission denied有人能告诉我如何正确地禁用挂起吗?
发布于 2020-12-12 18:04:50
经过进一步的研究,我找到了正确的答案:
在/etc/systemd/logind.conf中,在底部添加以下行:
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore然后跑
systemctl restart systemd-logind
以激活新设置。
https://serverfault.com/questions/1045949
复制相似问题