当前位置: 首页>>技术教程>>正文


如何禁用我的系统进入睡眠状态?

问题描述

我可以在较旧的AMD 2400+台式机上在家中安装Web服务器。我已经安装并正在运行Ubuntu 11.04,但是一段时间后,我无法再浏览到服务器。当我进入键盘并按下一个键时,一切都会神奇地恢复正常。

我已经浏览过BIOS,但没有看到任何省电功能已启用。在Ubuntu中有类似的东西吗?可以禁用吗?

我没有安装任何GUI。这仅是控制台。

最佳思路

在Ubuntu 16.04 LTS上,我成功使用以下命令禁用了暂停:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

并将其发送到re-enable:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

man systemctl

mask NAME...  
           Mask one or more units, as specified on the command line. This
           will link these unit files to /dev/null, making it impossible to
           start them. This is a stronger version of disable, since it
           prohibits all kinds of activation of the unit, including
           enablement and manual activation. Use this option with care. This
           honors the --runtime option to only mask temporarily until the
           next reboot of the system. The --now option may be used to ensure
           that the units are also stopped. This command expects valid unit
           names only, it does not accept unit file paths.

 unmask NAME...
           Unmask one or more unit files, as specified on the command line.
           This will undo the effect of mask. This command expects valid
           unit names only, it does not accept unit file paths.

次佳思路

图形用户界面

您是否看过:

系统->首选项->能源管理

在“交流电源”选项卡上,闲置以下时间,使计算机进入睡眠状态:”Never”

终奌站

您可以打开”gconf-editor”吗?

查找:/apps/gnome-power-manager/timeout

尝试将sleep_computer_ac设置为0

我也不太肯定是否需要更改其他内容。

第三种思路

located here的正确答案:

Have you tried adding the kernel options acpi=off apm=off to the GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub?

Then run sudo update-grub and reboot your computer.

第四种思路

请尝试查看以下链接-cyberciti.bizArch forums

这是cyberciti.biz链接的摘录:

By default, the Linux kernel will use screen-save option to disable it you need to type this command (it turns off monitor VESA powersaving features):

$ setterm -powersave off -blank 0 

If it dumps back you with an error that read as follows: cannot (un)set powersave mode

You need to shutdown X window system and rerun the above command. Better, add following two commands to your ~/.xinitrc file:

setterm -blank 0 -powersave off -powerdown 0 xset s off 

第五种思路

这些描述的解决方案都不适合我。笔记本电脑仍在睡觉。使用acpi = off的Grub Linux命令行选项导致笔记本电脑无法启动。我终于找到了解决方案。

sudo vi /etc/default/acpi-support # and then set SUSPEND_METHODS="none"
sudo /etc/init.d/acpid restart

基于Stephan的原始解决方案:Keep Ubuntu Server running on a laptop with the lid closed?

第六种思路

除了systemctl的mask /unmask选项,我还使用以下命令打开/关闭Gnome桌面的挂起。

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'suspend'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'suspend'

要么

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'

我通过探索How to dump ALL dconf/gsettings so that I can compare them between two different machines?中列出的命令揭示的设置找到了这些

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/9898.html,未经允许,请勿转载。