This logs the output of 'uptime' every five minutes. This output also includes the number of users currently logged on and load averages of your computer the last 1, 5 and 15 minutes:
sudo bash #root
mkdir /var/log/uptime
crontab -e
Add this line:
*/5 * * * * echo `date +\%Y\%m\%d;uptime` >> /var/log/uptime/uptime.log 2>&1
And to split+gzip the log into weekly files:
cat <<'EOF'. > /etc/logrotate.d/uptime
/var/log/uptime/uptime.log {
weekly
dateext
rotate 99999
compress
}
EOF
Then, after some time has passed, view your uptime for each day like this:
uplog() { (cd /var/log/uptime/;zcat uptime.log*gz;cat uptime.log) }
uplog|cut -c1-8|uniq -c|perl -aple'$_.=" ".("=" x ($F[0]/5))'
The number 288 (12*24) means the computer was up all day (although reboots shorter than five minutes may go undetected by this method).
Or similarly for each month like this:
uplog|cut -c1-6|uniq -c|perl -aple'$_.=" ".("=" x ($F[0]/150))'