4

How can I get the power-related events (Sleep, restart, wake-up) for the current system, like e.g.

2022-02-27T08:02:01 System Restarted
2022-02-28T08:34:32 Resumed from sleep
2022-02-28T15:15:11 Sleep activated

I don't care if it is in a log file, CLI or UI (e.g. Console App).

I tried that in the Console app already, but I can't see historic events (like from the past days but only from the point where I started the app). But maybe I'm doing something wrong here.

Background: I want to use it for roughly tracking my working hours without the need to actually actively tracking it. I moved from Windows which has the EventViewer app where I could see all those events with a special query for days and weeks in the past.

2
  • 1
    Does sudo last help?
    – nohillside
    Commented Feb 28, 2022 at 9:24
  • @nohillside I remember trying it and it was just printing one line or so. But just tried it again and it looks pretty good as well. So it's showing reboots/shutdown and also how long a user was logged on. So, that's pretty good!
    – jaw
    Commented Mar 1, 2022 at 11:07

1 Answer 1

8

The power management log can be shown with the Terminal command pmset -g log. The is, as you might expect, very verbose.

To make it more useful, I pipe the command into grep to select what I am interested in viewing. I frequently use one of these commands to see how often my MacBook wakes whilst it is supposed to be sleeping.

pmset -g log | egrep "\b(Sleep|Wake|DarkWake|Start)\s{2,}"

pmset -g log | grep -e "Wake from" -e "DarkWake" -e "due to"

You will need to experiment to find what you need.

2
  • Thanks for that suggestion. There is a lot of Sleep/Dark wake changes but there are also some informations missing. E.g. in sudo last, I saw some crashes that was not mentioned and it seems to hold the history only for 1 week whereas last seems to have a longer history. So I think for my use case last seems to be the better option.
    – jaw
    Commented Mar 1, 2022 at 11:18
  • 1
    @jaw whatever meets your needs. There is no easy and complete answer. There is LOTS of stuff if you know where to look. I am not an expert by any means, but I know that macOS keeps an extensive audit trail. praudit is a command gets into this. There are also sqlite databases for specific activities. Another way is to create your own - I have a KeyboardMaestro macro which records whenever I change window.
    – Gilby
    Commented Mar 1, 2022 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .