1

I have a brand new 20.04LTS Laptop that keeps going to sleep. When it goes to sleep, it does not wake up without a forced reboot (holding the power button).

I have disabled sleep and hibernate with this command:

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

It's been properly disabled, according to this output.

● sleep.target
     Loaded: masked (Reason: Unit sleep.target is masked.)
     Active: inactive (dead)

● suspend.target
     Loaded: masked (Reason: Unit suspend.target is masked.)
     Active: inactive (dead)

● 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)

It does not go to sleep after a specific amount of time. For example, it stayed powered on with the lid closed for a 5 hour car trip and unplugged the entire time. However, within 2 hours of plugging it in it went to sleep. Other times, it will go to sleep within 30 minutes of being unplugged. The longest I've had it go without going to sleep is about 36 hours.

How else can I prevent Ubuntu 20.04LTS from going to sleep or hibernating, especially when it is plugged in?

Andy
  • 233
  • 1
  • 6
  • 16
  • Your terminology is confused. "Sleep" suspends a process for a time. "Suspend" freezes the system in RAM, and enters a low power state. "Hibernate" writes the system to swap space on the disk enters a lower power state. When you "Resume" from "Suspend" or "Hibernate", you'll be presented with the lock screen. To see what happened with the previous failed system, use the terminal command `sudo journalctl -b -1 -xe`. Read `man journalctl` and `sudo journalctl --list-boots` to select other system shutdowns. – waltinator Apr 26 '22 at 02:00

1 Answers1

0

Preventing the computer from going to sleep can be set in the user interface, avoiding the need for terminal commands that potentially may be wrong.

In "Settings", "Power", there is a section "Power Saving Options". Set "Automatic suspend" to "Never" to prevent the computer to go into sleep state.

vanadium
  • 82,909
  • 6
  • 116
  • 186
  • This does not appear to be an option I have available: https://i.stack.imgur.com/UMBXr.png – Andy Apr 26 '22 at 12:31
  • I have this on 22.04. Try the command `gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0`, and for when on AC power: `gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0`. Change `set` by reset and leave out the 0 to reset to default. – vanadium Apr 26 '22 at 12:57