Linux系统禁用自动休眠功能(linux关闭自动休眠)

随着智能硬件的发展,物联网、虚拟云服务日渐普及,linux服务器运维变得更加重要,而有时候我们的服务器可能需要高频的使用,如果系统休眠了我们就无法在远程 access 上,因此就需要我们禁用系统的休眠功能,以下将介绍linux系统禁用自动休眠功能的方法。

首先,确保你已经登录 linux 系统,在登录状态下自动休眠功能是不会真正启动的,除此之外,可以运行以下命令来禁用 linux 系统自动休眠功能:

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

上面的命令禁用了所有休眠模式,也就是系统不能自动休眠了。如果你仅仅只想禁用休眠功能而继续使用 hibernate,可以运行如下命令:

`sudo systemctl mask suspend.target suspend-then-hibernate.target`

或者,如果你想要禁用 Hibernate 功能而继续使用休眠功能,可以运行:

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

上述命令执行完毕后,再次执行 systemctl 命令可以看到上面几个休眠模式被 mask:

`systemctl list-unit-files | grep -e suspend -e hibernate`

如果你想要重新启用这些休眠模式,只需要运行 `sudo systemctl unmask suspend.target` 命令来解除 mask 即可。

总而言之,通过以上方法,就可以非常方便的在 Linux 系统中禁用自动休眠功能,加强系统运行的稳定性。


数据运维技术 » Linux系统禁用自动休眠功能(linux关闭自动休眠)