Sec*_*Sec 2 ubuntu suspend systemd
我有一台安装了 ubuntu 20.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
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何正确禁用暂停?
经过更多的搜索,我找到了正确的答案:
在/etc/systemd/logind.conf
底部添加以下几行:
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
Run Code Online (Sandbox Code Playgroud)
并运行
systemctl restart systemd-logind
以激活新设置。
归档时间: |
|
查看次数: |
1679 次 |
最近记录: |