0

I want to use automator or terminal to fetch data from the mac console app.

In particular:

If you search for "sleepwake" in the console app › tab "Mac Analytics Data", you get the timestamps when you woke up the mac from sleep mode.

I want to get those timestamps (e.g. the last one) by some sort of automation.

Any idea?

User123456789
  • 377
  • 1
  • 4
  • 12

1 Answers1

0

You can use the a command line call to sysctl to get the last sleep and wake times:

sysctl kern.sleeptime kern.waketime

In my case, the output was:

kern.sleeptime: { sec = 1596154703, usec = 743388 } Fri Jul 31 01:18:23 2020
kern.waketime: { sec = 1596157070, usec = 25 } Fri Jul 31 01:57:50 2020
CJK
  • 426
  • 3
  • 8
  • thank you, this was exactly what I need. I also found kern.boottime but no command for the shutdown or user login time although they can be found in the console.app. Do you know the commands or the documentation for the kern-command? – User123456789 Aug 06 '20 at 09:35
  • Are you looking for a list of available identifiers you can retrieve with `sysctl` ? The ones that are in the `kern` array can be listed like so: `sysctl -N kern` (or without the `-N` flag to print the values as well). – CJK Aug 08 '20 at 06:40
  • thank you, that was what I needed – User123456789 Aug 08 '20 at 11:01