Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AWJJ

macrumors newbie
Original poster
Nov 13, 2019
1
0
Hi all,

I recently found a terminal command that is very useful for me: pmset -g log | grep 'Display is turned on' /or off

It lets me track the time spent actively on my mac. However, the logs only show the history of the past seven days. Is there any way to increase the time span of the log to e.g. several months?

Happy to hear your thoughts!

Right, and this is my first post here. Been more of a lurker so far. Please let me know in case this is in the wrong section.

Cheers,

Andi
 
Hi all,

I recently found a terminal command that is very useful for me: pmset -g log | grep 'Display is turned on' /or off

It lets me track the time spent actively on my mac. However, the logs only show the history of the past seven days. Is there any way to increase the time span of the log to e.g. several months?

Happy to hear your thoughts!

Right, and this is my first post here. Been more of a lurker so far. Please let me know in case this is in the wrong section.

Cheers,

Andi


On *nix systems the log files are rotated (deleted if set for this) but I think there are backups. Looks like they are in the /var/log/ directory like I would suspect from my linux system I checked on first.

Code:
MacUser2525:~$ ls -l /var/log/


total 175232


drwxr-xr-x   3 root             wheel             102B  6 Dec  2018 Bluetooth/


-rw-r--r--@  1 root             wheel              12B  9 Jul 18:31 CDIS.custom


drwxr-xr-x   2 root             wheel              68B 22 Feb  2018 CoreDuet/


drwxrwx---  34 root             admin             1.1K 14 Nov 00:00 DiagnosticMessages/


-rw-------   1 root             wheel             168K 22 Sep 18:23 SleepWakeStacks.bin


drwxr-xr-x   2 root             wheel              68B  4 Apr  2018 apache2/


drwxr-xr-x  28 root             wheel             952B 14 Nov 00:30 asl/


drwxr-xr-x   2 root             wheel              68B 31 May  2018 com.apple.xpc.launchd/


-rw-r--r--   1 root             wheel             531K  9 Nov 02:19 corecaptured.log


drwxr-xr-x   4 root             wheel             136B 13 Sep 14:11 cups/


-rw-r--r--   1 root             wheel             860K 14 Nov 00:08 daily.out


drwxr-xr-x   4 _displaypolicyd  _displaypolicyd   136B  7 Dec  2018 displaypolicy/


-rw-r--r--   1 root             wheel               0B  6 Dec  2018 displaypolicyd.stdout.log


drwxr-xr-x   3 root             wheel             102B  7 Oct  2017 emond/


-rw-r--r--   1 root             wheel             9.5K 19 Oct 22:41 fsck_apfs.log


-rw-r--r--   1 root             wheel             1.6M 14 Nov 00:09 fsck_hfs.log


-rw-r--r--   1 root             wheel             1.9K  6 Dec  2018 hfs_convert.log


-rw-r--r--@  1 root             wheel              82M 14 Nov 00:44 install.log


-rw-r--r--   1 root             wheel             117B 26 Mar  2019 kernel-shutdown.log


-rw-r--r--   1 root             wheel             3.7K 23 Oct 07:26 monthly.out


-rw-r--r--   1 root             wheel             5.1K 19 Oct 22:39 org.openzfsonosx.zconfigd.err


-rw-r--r--   1 root             wheel               0B  6 Dec  2018 org.openzfsonosx.zconfigd.log


-rw-r--r--   1 root             wheel             255K 19 Oct 22:39 org.openzfsonosx.zed.err


-rw-r--r--   1 root             wheel               0B  6 Dec  2018 org.openzfsonosx.zed.log


-rw-r--r--   1 root             wheel             2.9K 19 Oct 22:41 org.openzfsonosx.zpool-import-all.err


-rw-r--r--   1 root             wheel              33K 19 Oct 22:41 org.openzfsonosx.zpool-import-all.log


drwxr-xr-x@ 18 root             admin             612B 14 Nov 00:30 powermanagement/


drwxr-xr-x   2 root             wheel              68B 22 Jun  2018 ppp/


-rw-r-----@  1 root             admin              65K 14 Nov 01:07 system.log


-rw-r-----   1 root             admin              25K 13 Nov 23:00 system.log.0.gz


-rw-r-----   1 root             admin              26K 12 Nov 23:00 system.log.1.gz


-rw-r-----   1 root             admin              26K 11 Nov 23:00 system.log.2.gz


-rw-r-----   1 root             admin              25K 10 Nov 23:00 system.log.3.gz


-rw-r-----   1 root             admin              26K  9 Nov 23:00 system.log.4.gz


-rw-r-----   1 root             admin              25K  8 Nov 23:00 system.log.5.gz


-rw-r-----   1 root             admin              26K  7 Nov 23:00 system.log.6.gz


drwxr-xr-x   2 _uucp            wheel              68B  6 Oct  2017 uucp/


-rw-r--r--   1 root             wheel             4.4K 13 Nov 02:43 weekly.out


-rw-r--r--   1 root             admin              63B 14 Nov 00:30 wifi.log


-rw-r-----   1 root             admin             123B 14 Nov 00:30 wifi.log.0.bz2


-rw-r-----   1 root             admin             124B 13 Nov 00:30 wifi.log.1.bz2


-rw-r-----   1 root             admin             121B  4 Nov 00:30 wifi.log.10.bz2


-rw-r-----   1 root             admin             123B 12 Nov 00:30 wifi.log.2.bz2


-rw-r-----   1 root             admin             122B 11 Nov 00:30 wifi.log.3.bz2


-rw-r-----   1 root             admin             126B 10 Nov 00:30 wifi.log.4.bz2


-rw-r-----   1 root             admin             124B  9 Nov 00:30 wifi.log.5.bz2


-rw-r-----   1 root             admin             121B  8 Nov 00:30 wifi.log.6.bz2


-rw-r-----   1 root             admin             123B  7 Nov 00:30 wifi.log.7.bz2


-rw-r-----   1 root             admin             124B  6 Nov 00:30 wifi.log.8.bz2


-rw-r-----   1 root             admin             124B  5 Nov 00:30 wifi.log.9.bz2

Another useful command in terminal for you.

Code:
MacUser2525:~$ zgrep -R "Display is turned" /var/log/*


zgrep: /var/log/SleepWakeStacks.bin: Permission denied


Binary file /var/log/powermanagement/2019.10.31.asl matches


Binary file /var/log/powermanagement/2019.11.01.asl matches


Binary file /var/log/powermanagement/2019.11.02.asl matches


Binary file /var/log/powermanagement/2019.11.03.asl matches


Binary file /var/log/powermanagement/2019.11.04.asl matches


Binary file /var/log/powermanagement/2019.11.05.asl matches


Binary file /var/log/powermanagement/2019.11.09.asl matches


Binary file /var/log/powermanagement/2019.11.10.asl matches


Binary file /var/log/powermanagement/2019.11.11.asl matches


Binary file /var/log/powermanagement/2019.11.12.asl matches

It will show you which file contains the string you search for and the number of times it is found. You would of course want to add the on or off you search for on the end.

Edit: I would think you want to know how many times.

Code:
MacUser2525:~$ zgrep -R "Display is turned" /var/log/* | wc -l


zgrep: /var/log/SleepWakeStacks.bin: Permission denied


      10

Using the word count option to count the lines containing the output searched for.
 
Last edited:
On Mojave, your command gives me one week of info, like you said. Not sure where the pmset is getting that log info from, because '/var/log/powermanagement' has about two weeks of *.asl files.

The following 'log' command gives me about two weeks of info:

log show --style syslog --predicate 'senderImagePath contains[cd] "powerd"' --info | grep "Display state"

Does that help at all?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.