14

I'm running the latest Ubuntu Server (quite literally downloaded & installed yesterday) on a box under my desk. I've got trac installed and OpenSSH. Intermittently both become unavailable, as if the server has gone to sleep, which seems odd because to me, the whole idea of a server is that it's always on/available.

The server is only used on the LAN.

I've tried adding acpi=off to /etc/default/grub, running update and rebooting, no difference.

Currently, I have SSH open and if I leave it for some time, it will remain connected, but lag horribly when I go back to using it. Last time this sleep/hibernate issue happened, I had to plug in a keyboard and monitor to get it come back up.

Any ideas or suggestions?

3
  • Not sure it will work or not. Set sleep_computer_ac to 0 using gconftool-2 --set --type int /apps/gnome-power-manager/timeout/sleep_computer_ac 0 `
    – g_p
    Commented Aug 20, 2014 at 7:27
  • check your hdparm settings. what is the output of sudo hdparm -B /dev/sda
    – mchid
    Commented Apr 5, 2015 at 14:55
  • the reason I ask is because sometimes it may take a minute or two for the system to begin to respond properly after the disk spins down.
    – mchid
    Commented Apr 5, 2015 at 15:01

5 Answers 5

13

I understand this is an old post, but I had this same problem and had a hard time finding a decent answer.

My laptop with Ubuntu Server would go into a white screen saver, and soon after everything would lose connection to the server. As soon as I exited the screen saver with the keyboard on the laptop, everything was able to once again connect. The acpi=off, setterm -blank 0, and other options described on similar questions never worked, until I found a working answer from the Unix and Linux SE.

After this solution, my laptop still goes to the white screen saver, however I no longer lose connection to any of the services running on it (SSH, SFTP, HTTP).

This command disables suspend:

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

and this command brings it back:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
1
  • Do these settings stay intact even after we reboot the machine? Commented Jul 6, 2023 at 8:16
1

Try using

setterm -blank 0

It needs to be entered after every boot, but keeps things running.

5
  • can you give a little more information please
    – Panther
    Commented Apr 18, 2015 at 19:57
  • The setterm is the command, -blank is what the command adjusts, and 0 is the value of time used by the command.
    – user399131
    Commented Apr 19, 2015 at 20:33
  • What specifically would you like to know?
    – user399131
    Commented Apr 19, 2015 at 20:33
  • Did this solve the issue?
    – user399131
    Commented Apr 21, 2015 at 20:20
  • askubuntu.com/questions/138918/…
    – user399131
    Commented Apr 23, 2015 at 3:35
1

You might try Caffeine. You can either use the 'caffeinate' command to prevent your server from sleeping during a given commmand (see http://www.webupd8.org/2015/01/caffeine-app-gets-its-indicator-back.html for syntax) or just set it to prevent idle all the time.

2
  • 1
    Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears... :-( Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material...
    – Fabby
    Commented Jun 1, 2015 at 20:49
  • 1
    Why install a third party software to do what setterm -blank 0 already does?
    – Rodrigo
    Commented Oct 1, 2015 at 14:09
1

I found that I wanted a way that was a bit more knowledgeable about which sessions I wanted to keep awake. Luckily systemd has a facility for inhibiting sleep/hibernate, etc. with Inhibitor Locks and the tool systemd-inhibit.

The following will inhibit sleep:

sudo systemd-inhibit --mode=block --what=sleep tail --pid=$$ -f /dev/null

Here's a slightly more robust command that adds a bit of logging and sets some values to improve debugging when using systemd-inhibit --list it also inhibits sleeping when a laptop lid is cosed:

/usr/bin/systemd-inhibit \
  --mode=block --who="$0" \
  --what=sleep:handle-lid-switch --why="Requested by $USER" \
  /usr/bin/tail --pid=$$ -f /dev/null

Run that and put it into the background and the current shell will define the life of the sleep inhibitor.

-1

setterm -blank 0 added to the GRUB boot command typically is ignored by the kernel and I find myself having to use the arrow-up function to type it again quickly over and over. It seems to work after entering the command 15 or 20 times from a root terminal. I enter it as quickly as I can strike the 2 keys necessary (i.e., up arrow followed by the Enter key) and I usually can get a terminal to remain open.

Be advised that closing a terminal artificially held open via the setterm -blank 0 command` seems to be interpreted by the kernel as a totally erroneous "indication" that is has permissions to go independently into sleep/hibernation mode. I recommend that you start a root terminal in, say, tty2 or tty3, and leave it running. As long as the terminal program remains active, on my system at least, it does appear that I may be permitted to keep my console monitor up and running.

setterm -blank 0 does not address the problem of who gave the system permissions to go independently into sleep/hibernation mode and how I can get control of my system back. It's important to me that my file server should be on-line and available at all times. To keep my serer running, I am personally rewriting some kernel modules. After I get those mods in place I will permanently disable software updates and my problem will be solved, at least until I purchase some newer hardware that requires a newer kernel, and then, in order to keep my server running, I will be forced to rewrite parts of the kernel again.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .