确定上次暂停的时间和时长

确定上次暂停的时间和时长

我想知道上次系统挂起的时间和时长。可以吗?

编辑

dmesg | grep -A10 suspend
[27075.428135] PM: suspend of devices complete after 998.769 msecs
[27075.432139] PM: late suspend of devices complete after 4.000 msecs
[27075.432325] r8169 0000:02:00.0: System wakeup enabled by ACPI
[27075.448098] ehci-pci 0000:00:1d.0: System wakeup enabled by ACPI
[27075.452115] ehci-pci 0000:00:1a.0: System wakeup enabled by ACPI
[27075.460035] xhci_hcd 0000:00:14.0: System wakeup enabled by ACPI
[27075.464397] PM: noirq suspend of devices complete after 32.255 msecs
[27075.464646] ACPI: Preparing to enter system sleep state S3
[27075.464873] PM: Saving platform NVS memory
[27075.465405] Disabling non-boot CPUs ...
[27075.466662] kvm: disabling virtualization on CPU1
[27075.568014] smpboot: CPU 1 is now offline
[27075.569471] kvm: disabling virtualization on CPU2
[27075.672016] smpboot: CPU 2 is now offline
[27075.673417] kvm: disabling virtualization on CPU3
[27075.776020] smpboot: CPU 3 is now offline
[27075.777422] kvm: disabling virtualization on CPU4
[27075.880019] smpboot: CPU 4 is now offline
[27075.881376] kvm: disabling virtualization on CPU5
[27075.984012] smpboot: CPU 5 is now offline
[27075.984393] Broke affinity for irq 23
[27075.985396] kvm: disabling virtualization on CPU6
[27076.088010] smpboot: CPU 6 is now offline
[27076.089372] kvm: disabling virtualization on CPU7
[27076.192012] smpboot: CPU 7 is now offline
[27076.192213] ACPI: Low-level resume complete
[27076.192213] PM: Restoring platform NVS memory

答案1

看看这些行:

[27075.428135] PM: suspend of devices complete after 998.769 msecs
[27075.432139] PM: late suspend of devices complete after 4.000 msecs
...
...
[27076.192213] PM: Restoring platform NVS memory

这些,猜测显示它何时开始和结束暂停。因此,获取它开始暂停的时间的一种方法是:

dmesg | egrep -i "suspend|complete" | head -1 | cut -d ] -f1 | tr -d [

当它结束时

dmesg | egrep -i "resume complete" | head -1 | cut -d ] -f1 | tr -d [

因此,猜测暂停和恢复之间的时间的一种方法是:

expr "$(dmesg | egrep -i "resume complete" | head -1 | cut -d ] -f1 | tr -d [ | cut -d . -f1)" - "$(dmesg | egrep -i "suspend|complete" | head -1 | cut -d ] -f1 | tr -d [ | cut -d . -f1)"

可能有更好的方法来做到这一点......

(注意:使用dmesg -T显示时间可能不起作用 - 按照以下条目man dmesg

-T, --ctime

 打印人类可读的时间戳。时间戳可能不准确!

 系统 SUSPEND/RESUME 后,日志所使用的时间源不会更新。

相关内容