ubuntu 自动休眠 关闭
远程连接ubuntu 经常连不上,去机房看是自动关机了原因是之前厂商安装的是桌面版ubuntu ,默认有自动休眠,不用自动就休眠了。
查看是否开启了自动休眠。
sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
是的话会显示 enabled
● sleep.target - Sleep
Loaded: loaded (/lib/systemd/system/sleep.target; static; vendor preset: enabled)
Active: inactive (dead) since Mon 2024-02-26 10:10:47 CST; 1min 56s ago
Docs: man:systemd.special(7)
2月 22 17:49:49 tlrobot-pc systemd[1]: Reached target Sleep.
2月 26 10:10:47 tlrobot-pc systemd[1]: Stopped target Sleep.
● suspend.target - Suspend
Loaded: loaded (/lib/systemd/system/suspend.target; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
2月 26 10:10:47 tlrobot-pc systemd[1]: Reached target Suspend.
2月 26 10:10:47 tlrobot-pc systemd[1]: Stopped target Suspend.
● hibernate.target - Hibernate
Loaded: loaded (/lib/systemd/system/hibernate.target; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
● hybrid-sleep.target - Hybrid Suspend+Hibernate
Loaded: loaded (/lib/systemd/system/hybrid-sleep.target; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
关闭自动休眠
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.
ps:systemctl mask
命令用于屏蔽(禁用)指定的系统单元,使其无法被启动。
重新查看
sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
● sleep.target
Loaded: masked (Reason: Unit sleep.target is masked.)
Active: inactive (dead) since Mon 2024-02-26 10:10:47 CST; 6min ago
2月 22 17:49:49 tlrobot-pc systemd[1]: Reached target Sleep.
2月 26 10:10:47 tlrobot-pc systemd[1]: Stopped target Sleep.
● suspend.target
Loaded: masked (Reason: Unit suspend.target is masked.)
Active: inactive (dead)
2月 26 10:10:47 tlrobot-pc systemd[1]: Reached target Suspend.
2月 26 10:10:47 tlrobot-pc systemd[1]: Stopped target Suspend.
● hibernate.target
Loaded: masked (Reason: Unit hibernate.target is masked.)
Active: inactive (dead)
● hybrid-sleep.target
Loaded: masked (Reason: Unit hybrid-sleep.target is masked.)
Active: inactive (dead)