How to prevent computer from automatically sleeping and/or hibernating?
Solution 1
Here are the two common Gnome 3 ways which usually disable suspend; otherwise you can try booting with the acpi=off
parameter:
-
Power Settings:
-
gnome-tweak-tool
(install if necessary):
Solution 2
From System Settings or by searching in Dash, go to Power settings. You'll find what you need there ;)
And to prevent from locking, go to Brightness and Lock:
Solution 3
@Kaled Kelevra, I've created the file 00CPU and followed all the steps, unfortunately my machine still went to sleep after 10 minutes.
On the ArchLinux forums, I found a solution that worked for me. See answer #21.
This is how I fixed mine in /etc/X11/xorg.conf
:
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Evdev Mouse" "CorePointer"
Option "BlankTime" "0"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
I just added the 4 options you see there. Test it out and post back. Good luck.
Solution 4
Why not check out Caffeine application indicator. It does precisely what you want, and is very easy to use.
Solution 5
I don't know if you had solved that problem you have with suspend/hibernate, but if not, I've a script maybe solve it (I had the same problem and it worked for me). :) Create a script in the /etc/pm/sleep.d/ directory ("sudo gedit /etc/pm/sleep.d/ 00CPU", for example) with the following content:
#!/bin/sh
# Workaround for concurrency bug in xserver-xorg-video-intel 2:2.4.1-1ubuntu10.
# Save this as /etc/pm/sleep.d/00CPU
. "${PM_FUNCTIONS}"
case "$1" in
hibernate|suspend)
for i in /sys/devices/system/cpu/cpu*/online ; do
echo 0 >$i
done
;;
thaw|resume)
sleep 10 # run with one core for 10 secs
for i in /sys/devices/system/cpu/cpu*/online ; do
echo 1 >$i
done
;;
*)
;;
esac
Then just give the script execute permission (sudo chmod 755 00CPU) and... that's all! Enjoy your Ubuntu.
P.S.: sorry for my english. P.S.2.: you can change the "sleep 10" value, with "sleep 5" for example, so your second processor core will run a bit earlier.
Note: It seems to be a concurrency problem with some kernels versions and determinate multi-core processors.
Related videos on Youtube
Mark E. Haase
Hi! I have been working full-time as a software engineer since I graduated from college in 2005. I began coding when I was 13, and I have loved it ever since. My main interest area is information security – or cyber if you prefer – and in addition to writing security software for a long time, I have also done some penetration testing work. In the last three years, I have been working as a contractor on a DARPA R&D contract involving web crawling, dark web, and machine learning. My main strength is developing web applications in high-level languages – Python is my favorite – but I consider myself more of a general hacker who is comfortable working with a wide range of technologies and learning whatever I need to accomplish the task at hand. (I suppose that full-stack is the trendy term.) In my study of infosec, I have spent a lot of time learning to read assembly and reverse engineer applications to develop exploits. (I have the OSCP, CISSP, and CEH certifications.) I have released a couple of work projects as open source. I created an easy-to-use web crawler called Starbelly, as well as a database migrations system called Agnostic. And if you want to get really nerdy with me, I wrote a tiny utility called sshadduser that simplifies the error-prone process of giving somebody SSH access to a server. I also like writing and teaching. In addition to developing infosec courses for government clients, I also participate here on Stack Overflow and infrequently publish on my tech blog. I have been working full-time remote for several years now out of my home office in the Washington DC area. I am seeking contract work (1099) for 2018.
Updated on September 18, 2022Comments
-
Mark E. Haase over 1 year
I'm running Ubuntu 12.04, and my laptop* won't wake from sleep/suspend/hibernate. (Is sleep the same thing as suspend?) I'm not even sure which of these things it's doing. When I am done working for the day, I lock my screen (Control-Alt-L). When I come back the next day, the screen is in power saving mode, and no amount of typing or clicking (on the usb keyboard/mouse or the builtin keyboard/trackpad) nor tapping the power button will bring it back to life.
The only way I can get my machine to work is to hold down the power button until it shuts off, then press the power button again to turn it back on. Obviously, anything I had open from the previous day is pretty much gone -- in particular, my VMs all get rudely shut down without any warning.
This is driving me INSANE. I spend the first hour of every work day trying to figure out how to get my computer to stop locking up over night.
What I've tried:
- Editing the org.freedesktop.upower.policy to disable suspend and hibernate.
- Setting power management options in "Power" section of "System Settings".
- Looking at all power management options in the BIOS (none appear to be relevant to sleep/suspend/hibernate).
- Reading every forum post/askubuntu post that I can find that's even tangentially related to the subject.
- Add acpi=off to kernel args. (Results in USB keyboard and mouse not working, so I didn't wait to see if it fixes the suspend.)
- Add apm=off to kernel args.
My question: how to disable the automatic sleep and/or hibernate (and/or anything similar) in Ubuntu 12.04. I don't care if it's still possible to sleep/suspend/hibernate/whatever by pushing buttons or running some command or reciting led zeppelin lyrics backwards. I just want my laptop to be ready for work in the morning.
*The laptop is a Dell Latitude something or other. I don't want to get too specific because I've seen a lot of similar questions get closed for being too specific. I think my question is generic enough to stand -- it's a question about the latest, stable version of Ubuntu.
Link to dmesg
Link to /var/log/kern.log
EDIT:
Nothing I've tried so far has prevented Ubuntu from sleeping at night, and when it does sleep, nothing I have tried can reliably get it to wake back up. I've seen a few posts that say buggy video drivers can cause problems with waking.
Last night, on a hunch, I tried switching to console (ctrl+alt+1) before leaving work, just to see what would happen. This morning when I woke up the computer, it instantly woke up back to the console. I switched over to Gnome (ctrl+alt+7) and although the screen looked frozen, I typed my password, pressed enter, and made some coffee. When I got back a few minutes later, my desktop was ready, just like I left it last night.
I'm going to keep trying this to see if this is a reliable solution.
EDIT 2:
No dice. Switching to the console after logging out does nothing for me... still have to reboot my computer each morning. It's driving me nuts... I can't believe how erratic suspend is on Ubuntu. Or the fact that it can't simply be disabled.
-
reverendj1 almost 12 yearsMost people have xscreensaver installed... :-)
-
Mark E. Haase almost 12 yearsSorry, I should have mentioned: I'm not running Unity. I'm running Gnome. Gnome has a dashboard but typing "screen" and/or "saver" doesn't have any hits.
-
Mark E. Haase almost 12 years@Mitch Gnome 3.
-
Mark E. Haase almost 12 yearsWell, my computer managed to wake from sleep after sleeping all weekend, and then it woke from sleep again after sleeping Monday night. I don't think I actually changed anything since the last time I posted here, so I'm not sure why it's suddenly working. I'm selecting this post as the correct answer because it is the most thorough.
-
Mark E. Haase almost 12 yearsScratch that last comment. After working twice in a row, it's now failed every single day since then. I'm about ready to throw this computer out the window.
-
Tharindu Kumara over 11 yearsI installed the gnome-tweak-tool and saw that on my Dell GX620 I had suspend set for Laptop lid close action on battery and for Laptop lid close action when on AC. The weird thing is that my Dell GX620 is not a laptop but a USSF (Ultra Small Form Factor) mini-tower. I've just changed these settings to Nothing and will confirm tomorrow if this change will have prevented it from going to sleep.
-
shaby over 7 yearsI need to find "Brightness and Lock" option to disbale power off automatically.
-
Thomas Ward almost 7 yearsIf the answer from another question directly helps this one, and the questions are similar, consider flagging this question as a duplicate of the other one, instead of copying your answer many times.
-
Spencer D about 5 yearsBe warned: I used the Ubuntu Caffeine application indicator recently in an attempt to keep on of my desktops (running 18.04.2 LTS on 4.15.0-46) turned on and accessible while I was out of town, and despite being activated/enabled, the system still ended up suspending/hibernating which made it inaccessible while I was away. After that experience, I would recommend sticking with the accepted answer (i.e., disabling automatic suspension), but your mileage may vary.