20

Is it possible to get the reason of system wake-up (Wake-on-LAN, Power button, wake from USB) on Linux? I'm using Ubuntu, kernel Linux homeless 2.6.37-12-generic #26~lucid1-Ubuntu SMP Wed Jan 5 21:52:06 UTC 2011 i686 GNU/Linux

honzas
  • 323
  • 2
  • 8
  • 3
    I'm not a linux expert, but if this is possible it may be distribution specific so you might want to include which distribution you're working with. This is usually a good idea with any question you ask of any OS. – squillman Jun 14 '11 at 15:18
  • I think it is not very distro-specific (maybe it is stored somewhere in /sys or /proc), but I am using: Linux homeless 2.6.37-12-generic #26~lucid1-Ubuntu SMP Wed Jan 5 21:52:06 UTC 2011 i686 GNU/Linux – honzas Jun 14 '11 at 15:59
  • I'd really like to know as well! In my case I'd like to know if my machine woke up because of the RTC alarm (in which case it should go back to sleep after running a little script) or because I pressed a keyboard key (in which case it shouldn't go back to sleep until I say so). – Stefan Sep 21 '14 at 15:37

2 Answers2

6

Depending on your hardware, you can find this using dmidecode:

$ sudo dmidecode |grep Wake-up
    Wake-up Type: Power Switch

There is lots of other useful hardware info from dmidecode, like the make/model/serial number of your motherboard/DIMMs/CPUs

In ubuntu it comes with the package dmidecode, should be available even in Lucid.

feitingen
  • 120
  • 1
  • 4
  • 5
    As far as I can tell, that always says "Power Switch". – Sec Feb 12 '15 at 08:42
  • 3
    Yeah, that just gives hardware info rather than activity logging. But on this note - how can you tell if a motherboard supports wake on lan via `dmidecode`? All my machines say "Power Switch" – Sridhar Sarnobat Jul 06 '17 at 17:21
  • This works for me. If I wake my computer up with the keyboard, it shows `Wake-up Type: PCI PME#`. If the computer was awakened by the RTC clock, it shows `Wake-up Type: APM Timer`. – Zoltan Jan 17 '21 at 09:53
1

This sorta explains it at the hardware level. What do you see when you dmesg | grep -i 'acpi'?

Lekensteyn
  • 6,546
  • 5
  • 27
  • 48
songei2f
  • 389
  • 1
  • 3
  • 13
  • 1
    Yes, I know abou /proc/acpi/wakeup and I'm using it on another machine and it selects which devices are allowed to wakeup the system. But after the wakeup I'm unable to say which of these devices causes the wakeup. – honzas Jun 14 '11 at 16:02
  • Hence I ask: does grepping the kernel log not tell you what wakes up the device via ACPI? I tried grepping it on a desktop, so I obviously did not find anything fun there. – songei2f Jun 14 '11 at 17:14
  • This [a pretty old message about a kernel bug](http://help.lockergnome.com/linux/17-dmesg-flooded-ohci_hcd-0000-00-02-wakeup--ftopict365240.html), it specifically shows while debugging ACPI issues in 2.6.17 and beyond that it will list the device by PCI bus designation (or whatever the hell that is), and say wakeup, no? – songei2f Jun 14 '11 at 17:52
  • I have tried it but there is no difference between dmesg after WOL and power button. – honzas Jun 14 '11 at 18:38
  • 1
    Interesting. When Googling about it, a lot of people complained about noisy debug logs. It might be they subsequently changed the logging level to be quieter *by default*, and [you need to up the noise if you want to see the old stuff](http://lwn.net/Articles/237085/). – songei2f Jun 14 '11 at 20:25
  • 1
    This might be even more useful, [a list of debug params you can pass that specify the specific kinds of ACPI info you want to see](http://www.mjmwired.net/kernel/Documentation/acpi/debug.txt#115). – songei2f Jun 14 '11 at 20:39
  • @ajstein: the "pretty old message" you link to is about "USB suspend" (i.e. power saving for currently idle USB devices), not about suspending/wakingup the computer. – Stefan Sep 21 '14 at 15:34
  • The link is dead. Any chance you can incorporate what it said in the answer itself? – fifaltra Mar 26 '19 at 17:40