My wife and I have been gaming through steam on my Ubuntu based Linux laptop. I want to know which of us have played more this month. We play different games, so adding up play times by game run time is possible. The problem is I don't know where or if there is even a log that would have this information. The syslog only keeps a days worth of data, and steam only has total play times for each game. Does anyone know of a log or way to find this info?
1 Answer
Since according to the original question, the syslog would satisfy the need except that syslog only has about a day's worth of data.
Somehow, be it perl, sed/awk, or something else, the recent material can be gleened from syslog. What's also needed is to routinely gather this information from syslog, appending it to what has already been gleened. It's also important to insure you don't gleen the same entries more than once thus .
- the gleen needs to be done on a schedule
- syslog needs to be 'rolled over'.
Scheduling would be achieved by running the gleener and syslog roll-over as a shell invoked via crontab. The syslog roll-over is going to have to be done using root thus the cron-job will need to run from root's crontab (as in sudo crontab -e
).
I use a shell to regularly roll over my syslog. That code, run as
sudo logswitch.sh
is as follows:
#!/bin/bash
# logswitch.sh starts a new syslog
# moving the previous three versions down
#
rm /var/log/syslog.4.gz
mv /var/log/syslog.3.gz /var/log/syslog.4.gz
mv /var/log/syslog.2.gz /var/log/syslog.3.gz
tar -czf /var/log/syslog.2.gz /var/log/syslog.1
chown syslog /var/log/syslog.2.gz
chgrp adm /var/log/syslog.2.gz
rm /var/log/syslog.1
cat /var/log/syslog > /var/log/syslog.1
chown syslog /var/log/syslog.1
chgrp adm /var/log/syslog.1
cat /dev/null >/var/log/syslog
chown syslog /var/log/syslog
chgrp adm /var/log/syslog
service rsyslog restart
sudo journalctl -list-boots
, andsudo journalctl -b 0
.man pacct
, and be surelogrotate
is working) could tell you apart. Process Accounting can use a lot of disk space, so it's OFF by default.