# 服务器ubuntu 20.04关闭自动休眠模式

**URL:** <https://www.shiwantech.xyz/t/topic/221>\
**Category:** UBUNTU\
**Created:** [2024 年10 月 13 日 12:47 UTC](https://www.shiwantech.xyz/t/topic/221 "2024-10-13T12:47:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![itpanpan163](https://www.shiwantech.xyz/letter_avatar_proxy/v4/letter/i/ccd318/32.png) [@itpanpan163](https://www.shiwantech.xyz/u/itpanpan163)\
发布日期： [2024 年10 月 13 日 12:47 UTC](https://www.shiwantech.xyz/t/topic/221/1 "2024-10-13T12:47:15Z")

</div>

ubuntu图形界面中无论怎么设置，系统还是会自动休眠挂机，直到碰到了如下的方法:

1.查看是否开启休眠模式  
systemctl status sleep.target  
发现如下所示：  
● sleep.target - Sleep  
Loaded: loaded (/lib/systemd/system/sleep.target; static; vendor preset: enabled)  
Active: inactive (dead)  
Docs: man:systemd.special(7)

2.执行关闭休眠功能的命令，如下：  
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.

3.观察系统休眠状态，如下：  
systemctl status sleep.target  
可以看到自动休眠模式已被关闭：  
● sleep.target  
Loaded: masked (Reason: Unit sleep.target is masked.)  
Active: inactive (dead)
