Link to home
Start Free TrialLog in
Avatar of 1902 Software
1902 Software

asked on

Check and disable power saving mode in a headless Ubuntu 18.04 server

I have a newly configured, headless, Ubuntu 18.04 dedicated server on a hosting company, so it's not a local server.

The problem is that while I am connected and doing something on the server using SSH, running top, transferring a file, etc, I get disconnected and cannot connect again. I have to reboot the server to do so.

The hosting company says the server is configured to have power saving mode turned on, and it goes into power saving mode.

I find it weird because:
1. I never had encountered a server OS with power saving mode turned on, because, well, it's a server
2. Even it it was turned on, it should not kick in while it's in use. At lease that's how I understand how it should work
3. The server is almost 2 months old, and we only encountered this issue twice. Had it been on all the time, it would have been a constant problem since day 1

So my question is, how do I check that power saving mode is on, and how do I turn it off? I've read some articles in other sites, but I'd rather have the answers here.

Thanks in advance!
Avatar of dfke
dfke

Hi,

if you have a keyboard with power save buttons first issue:
gconftool -s /apps/gnome-power-manager/buttons/hibernate -t string interactive

Open in new window

Create a custom executable script like:
sudoedit /etc/pm/sleep.d/00disable-hibernate-suspend

Open in new window

To prevent the server from going into hibernation or suspend.

#!/bin/sh
# prevent hibernation and suspend features
. "$PM_FUNCTIONS"
case "${1}" in
  suspend|hibernate)
    inhibit
    ;;
  resume|thaw)
    exit 0
    ;;
esac

Open in new window

Make the file executable:
chmod 0755 /etc/pm/sleep.d/00disable-hibernate-suspend

Open in new window

Cheers
Avatar of 1902 Software

ASKER

Thank you dfke.

There is no '/apps/'. I assume that is a folder?

Is there a way where we can see if the server actually went into hibernate or sleep mode? A log perhaps?

I'm going to ask the hosting company to check their hardware first, as really unusual (at least in my experience) for a server to be configured out of the box with power saving mode on.

I'll try the script you provided otherwise.
Hi,

it might be in some other path:
sudo find / -xdev -name gnome-power-manager

Open in new window

However you can skip that part as it's just to disable any special powersave keys or key combinations that will (accidentally) initiate hibernation.

Cheers
Thanks again!
I tried both dfke's suggestions, and it did not work. I still got disconnected.

Searched some more and found the below. It's working so far:
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Hi,

good to hear that you solved the issue yourself.

Happy to help here anyways.

Cheers
Thanks again for the help
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.