16

I'm having a problem with my notebook suspending, but then waking up when I don't want it to (either immediately, or much later when in the bag - I may have two issues to solve here). But for the moment this question is about troubleshooting: is there a command I can run that will tell me what the trigger was for the last resume action? E.g. whether a key was pressed, or the power button, whether it was a wake-on-lan signal, whether it was switching from AC power to batter, etc, etc.

It appears that on Windows you can type powercfg -lastwake to find this out. So I'm looking for the Linux equivalent of that command.

If there is no such command, what do I need to look for, in which log file?

(Mint 16, xfce, Lenova Thinkpad, kernel 3.11.0-12-generic)

Darren Cook
  • 984
  • 2
  • 9
  • 19

4 Answers4

9

For the sake of completeness, there is another solution mentioned in this answer to a similar question.

Awakened by power button:

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

Awakened by RTC clock:

$ sudo dmidecode | grep Wake-up
    Wake-up Type: APM Timer

Awakened by keyboard:

$ sudo dmidecode | grep Wake-up
    Wake-up Type: PCI PME#
Zoltan
  • 446
  • 5
  • 16
  • I made this answer a community wiki as all credit goes to the original answer linked above. If you upvote this answer, please consider upvoting the original one as well. – Zoltan Jan 17 '21 at 10:09
5

Systems with systemd

On systems that make use of systemd you can look through systemd's log using the journalctl command.

Example

Here, for example my system went to sleep from the lid being closed and then when I opened it, you'd see events related to this like so:

$ journalctl | less
...
May 19 09:04:47 greeneggs.bubba.net kernel: PM: Syncing filesystems ... done.
May 19 09:04:47 greeneggs.bubba.net kernel: PM: Preparing system for mem sleep
May 19 09:33:42 greeneggs.bubba.net kernel: Freezing user space processes ... (elapsed 0.002 seconds) done.
May 19 09:33:42 greeneggs.bubba.net systemd[1]: Time has been changed
May 19 09:33:42 greeneggs.bubba.net systemd-logind[772]: Lid opened.
...

Systems without systemd

For systems that do not use systemd you have a variety of places to look. You could for starters look in the dmesg log. You could also look in /var/log/syslog for messages related to power management or ACPI related events.

I would start by taking a look in /var/log/pm_suspend.log, assuming it exists. Especially on distros such as Linux Mint, you'll likely find messages like this there:

Thu Feb 21 21:21:50 GMT 2013: Running hooks for hibernate.
Running hook /usr/lib/pm-utils/sleep.d/000kernel-change hibernate hibernate:
/usr/lib/pm-utils/sleep.d/000kernel-change hibernate hibernate: success.
Running hook /usr/lib/pm-utils/sleep.d/00logging hibernate hibernate:
...

References

karora
  • 148
  • 5
slm
  • 363,520
  • 117
  • 767
  • 871
3

Since you've got a ThinkPad, besides the other suggestions (preliminary the systemd hint), if you're using the thinkpad_acpi driver, you might want to have a look at /sys/devices/platform/thinkpad_acpi/wakeup_reason. This file contains a number telling you whether the embedded controller woke up your laptop for reasons like low battery (at least I thought it did), dock-removal request, etc.

As Documentation/laptops/thinkpad-acpi.txt states:

wakeup_reason:
    Set to 1 if the system is waking up because the user
    requested a bay ejection.  Set to 2 if the system is
    waking up because the user requested the system to
    undock.  Set to zero for normal wake-ups or wake-ups
    due to unknown reasons.
Andreas Wiese
  • 10,112
  • 1
  • 32
  • 38
-1

You can start with dmesg, check man dmesg but you might want to try dmesg -k.

taddy hoops
  • 240
  • 2
  • 7
  • `dmesg -k | wc -l` gives 3298 :-) BTW, does this tell me something different to looking at `/var/log/kern.log` ? – Darren Cook May 27 '14 at 01:59
  • @DarrenCook just identify when the suspend/resume happened and analyse that section which will `wc -l` to much less. – taddy hoops May 27 '14 at 02:06