[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
 


KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,157
Reaction score
6,994
Credits
66,234
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.
 
OP
P

pijack

New Member
Joined
Oct 18, 2021
Messages
6
Reaction score
1
Credits
54
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
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,157
Reaction score
6,994
Credits
66,234
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.
 
OP
P

pijack

New Member
Joined
Oct 18, 2021
Messages
6
Reaction score
1
Credits
54
there it is:

Bash:
[email protected]:~$ 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)


[email protected]:~$ 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)

[email protected]:~$ systemctl status hybernate.target
Unit hybernate.target could not be found.

Thanks
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,157
Reaction score
6,994
Credits
66,234
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.
 
OP
P

pijack

New Member
Joined
Oct 18, 2021
Messages
6
Reaction score
1
Credits
54
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:

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,157
Reaction score
6,994
Credits
66,234
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.
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,157
Reaction score
6,994
Credits
66,234
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.
 
$200 Digital Ocean Credit
Get a free VM to test out Linux!


Staff online

Members online


Latest posts

Top