Ubuntu wakes up after few seconds of sleep [duplicate]
Solution 1:
I had a very similar problem; I will show you an example but you will need to adapt it to your computer. The output here is from my desktop (and trimmed down), so apply cum grano salis.
Check the wakeup events for your PC:
2& [romano:~/etc] % cat /proc/acpi/wakeup
Device S-state Status Sysfs node
PCI0 S4 *disabled no-bus:pci0000:00
COM1 S4 *disabled pnp:00:06
PEGH S4 *disabled
PEGL S4 *disabled
IGBE S4 *enabled pci:0000:00:19.0
PCX1 S4 *disabled pci:0000:00:1c.0
PCX5 S4 *disabled pci:0000:00:1c.4
PCX7 S4 *disabled pci:0000:00:1c.6
HUB S4 *disabled pci:0000:00:1e.0
EUS1 S3 *enabled pci:0000:00:1d.0
EUS2 S3 *enabled pci:0000:00:1a.0
PBTN S4 *enabled
The enabled
events are the one that can wake up your computer. One of these is firing up in your case; you have to discover which one.
You can toggle the wakeup status on, for example, EUS1
(whatever it means --- no idea) with the command:
echo EUS1 | sudo tee /proc/acpi/wakeup
and then you can check that the wakeup is disabled, by repeating the first command. Now you can try to suspend and see if the PC stays suspended or not. Repeat.
Do not disable the event on PBTN
--- it is the power button. You can be unable to resume in that case!
My strategy is normally to disable everything minus the PBTN
--- now the resume should be trigger only with the power button. You can then try to reenable other sources (or not).
Once you have found the culprit(s) event(s), you can add them to your /etc/rc.local
to make the change permanent. Notice however that the interface is really badly thought, and you can only toggle the status of enabled/disabled, not set it; so for example to disable the EUS1 independently on its status you should use
grep 'EUS1.*enabled' < /proc/acpi/wakeup >/dev/null && echo "EUS1" > /proc/acpi/wakeup
in your /etc/rc.local
.
In my case the culprit where EHC y XHC devices, probably because I have an USB keyboard (not sure though), this is en excerpt of my rc.local
:
for device in XHC EHC1 EHC2; do
grep $device /proc/acpi/wakeup | grep enabled > /dev/null && {
echo Disabling wakeup on $device
echo $device > /proc/acpi/wakeup
}
done