[Ubuntu server 20.04 lts] Ubuntu goes to sleep

pijack

New Member
Joined
Oct 18, 2021
Messages
6
Reaction score
1
Credits
54
Hi,
I installed Ubuntu server 20.04 LTS on one of my laptops. It works great and fits my little needs for my Home Lab, but I noticed that it seems to go to sleep after a few hours (maybe).
I still haven't figured out if it has something to do with the system itself or the laptop (as far as I know it could be its network card as well).
Anyway, when it happens, I even can't connect to it via ssh, and I need to send commands directly on the machine to "wake it up".
Could you please help me fix it?

Thanks
 


Yes, yes it does.

It's one of my most popular articles, very nearly the top Google result. :)


I have no idea why sleep is enabled by default.
 
Yes, yes it does.

It's one of my most popular articles, very nearly the top Google result. :)


I have no idea why sleep is enabled by default.

Yes, I had already read it yesterday. But I am not sure if it is the cause of the problem. They seem inactive already.
Thanks
 
If that didn't help, my first guess would be that you didn't follow the article correctly? I dunno...

It has helped *thousands* of people with the exact same problem. (It's one of my most popular articles.)

But, we can verify this. Run the following three commands (You'll have to press Q to quit the output between the commands):

Code:
systemctl status sleep.target

Code:
systemctl status suspend.target

Code:
systemctl status hibernate.target

Each one should contain a line about it being dead AND masked. Like so:

hhPIUJn.png


Check all those. They should be dead. If they're dead and it's still happening, the problem isn't power management I don't think. We'll then have to explore other options.
 
there it is:

Bash:
luke@server:~$ 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)


luke@server:~$ systemctl status suspend.target
● suspend.target - Suspend
     Loaded: loaded (/lib/systemd/system/suspend.target; static; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:systemd.special(7)

luke@server:~$ systemctl status hybernate.target
Unit hybernate.target could not be found.

Thanks
 
Yup, you gotta run all the mask commands. (And not the unmask command.)

Then, when you check the status, you'll see they're dead *and* masked.

If you've got it working now, you can check and see, then you can edit your first post to add [Solved] to it.
 
Yup, you gotta run all the mask commands. (And not the unmask command.)

Then, when you check the status, you'll see they're dead *and* masked.

If you've got it working now, you can check and see, then you can edit your first post to add [Solved] to it.
Yes, they are masked now, except the "hybernate" one which still is shown as:
Unit hybernate.target could not be found.

By the way, I'd like to know why they should be also masked. What exactly does it mean, and why is this necessary to fix the problem completely?

I'll let you know if they fix the problem. Thanks
 
Last edited:
Masked simply means they don't get loaded.

I misspelled hibernate. There's no Y in it. My bad. I dunno why I spelled it with a Y... Run the command again, but use the 'hibernate' - I fixed the code above. Amusingly, I spelled it properly everywhere else.

Linux is pretty particular about spelling and capitalization. My bad.

Anyhow, masking the service is basically just telling the services to not run. You can mask and unmask services, though you will need some of them to run properly. These three do not need to be running processes.

I have no idea why it hibernates or sleeps by default. I just know that I discovered it while playing around and decided to tell folks how to fix it.

So, be sure to run the command again with the proper spelling.
 
Oh, and if you wanted a more specific answer...

Masking makes it a symlink that points at /dev/null (nothing). You could delete services, but masking means they still exist and can be restored to the unmasked condition. If you deleted the services, you'd have to recreate them if you wanted to use them again. That's a pain in the butt, so masking and unmasking exist.
 

Members online


Top