如何在Linux中禁用挂起和休眠
【小Y 提示】文章内容收集整理于网络,仅供参考!如需了解“如何在Linux中禁用挂起和休眠”等有关服务器、云主机租用、托管、配置、价格问题,请免费咨询YINGSOO客服,享受1v1贴心服务!
【热搜主机】服务器优惠 | 美国云服务器 | 台湾600M服务器
【导购指南】云主机是什么?
如果要防止Linux计算机挂起和休眠,请在系统级别禁用以下目标:
$ 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.
保存所有(以防万一),然后运行以下命令以应用更改:
$ sudo systemctl restart systemd-logind.service
或者,重新引导系统以使其生效。
检查更改是否已真正应用:
$ systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
样本输出:
● sleep.target
Loaded: masked
Active: inactive
● suspend.target
Loaded: masked
Active: inactive
● hibernate.target
Loaded: masked
Active: inactive
● hybrid-sleep.target
Loaded: masked
Active: inactive
从上面的输出中可以看到,suspend和hibernate系统目标已被屏蔽并且处于非活动状态。
要在系统上重新启用挂起和休眠状态,只需运行:
$ sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
样本输出:
Removed /etc/systemd/system/sleep.target.
Removed /etc/systemd/system/suspend.target.
Removed /etc/systemd/system/hibernate.target.
Removed /etc/systemd/system/hybrid-sleep.target.
如果只想防止在关闭盖子时挂起,请编辑文件/etc/systemd/logind.conf:
$ sudo nano /etc/systemd/logind.conf
添加/修改以下行:[Login] HandleLidSwitch=ignore HandleLidSwitchDocked=ignore
保存并关闭文件。不要忘记重启systemd-logind .service或重启系统以使更改生效。
有关更多详细信息,请查看手册页。
$ man logind.conf
畅销产品:美国高防服务器租用去首页参与活动!YINGSOO推出Phala挖矿服务器、Chia奇亚农场服务器、Swarm物理节点服务器、Swarm母鸡服务器、Swarm云节点服务器、国内矿机服务器海外托管、《Phala PHA挖矿资料大全》,《swarm bzz挖矿资料大全》,Swarm Bee节点租用请咨询YINGSOO客服!官网WWW.YINGSOO.com
版权声明:本站文章来源标注为YINGSOO的内容版权均为本站所有,欢迎引用、转载,请保持原文完整并注明来源及原文链接。禁止复制或仿造本网站,禁止在非www.yingsoo.com所属的服务器上建立镜像,否则将依法追究法律责任。本站部分内容来源于网友推荐、互联网收集整理而来,仅供学习参考,不代表本站立场,如有内容涉嫌侵权,请联系alex-e#qq.com处理。