7

I have notebook and want to store information for every day, when computer is running or not (with precise to minutes).

Here is output from last command:

dima     tty1         :0               Sat Apr 14 21:56    gone - no logout
reboot   system boot  4.15.15-1-ARCH   Sat Apr 14 21:56   still running
root     tty2                          Sat Apr 14 21:18 - 21:56  (00:37)
dima     tty1         :0               Sat Apr 14 20:38 - down   (01:17)
reboot   system boot  4.15.15-1-ARCH   Sat Apr 14 20:38 - 21:56  (01:17)
dima     tty1         :0               Sat Apr 14 12:36 - down   (06:19)
reboot   system boot  4.15.15-1-ARCH   Sat Apr 14 12:36 - 18:56  (06:19)
dima     tty1         :0               Thu Apr 12 20:08 - down  (1+16:28)
reboot   system boot  4.15.15-1-ARCH   Thu Apr 12 20:07 - 12:36 (1+16:28)
dima     tty1         :0               Thu Apr 12 13:33 - down   (06:34)
reboot   system boot  4.15.15-1-ARCH   Thu Apr 12 13:32 - 20:07  (06:34)

I want something like that, but also with information about when my notebook get to suspend/resume.

Could you say, please, which command should I use?

diralik
  • 227
  • 1
  • 8

1 Answers1

8

If systemd is your init system, then you can see it in that manner (works from root only):

[root@centos7 src]# journalctl -t systemd-sleep
-- Logs begin at Sat 2018-04-14 23:06:52 MSK, end at Sun 2018-04-15 01:30:01 MSK. --
Apr 15 00:18:55 centos7.localdomain systemd-sleep[3365]: Suspending system...
Apr 15 00:23:14 centos7.localdomain systemd-sleep[3365]: System resumed.

If you use initd as init system, then you can grep your dmesg for one of this patterns (output depend on kernel version and kernel distribution):

# entering to suspend state
kernel: PM: Preparing system for freeze sleep
# exit from suspend state
kernel: Suspending console(s) (use no_console_suspend to debug)
kernel: PM: suspend of devices complete after 60.341 msecs
Yurij Goncharuk
  • 4,177
  • 2
  • 19
  • 36