Wednesday, June 10, 2009

Archive portage logs

Just dump the following script in /etc/cron.daily to compress old portage logs and delete ancient ones, without using logrotate or tmpwatch/tmpreaper. After a year of running lappy, my /var/log/portage dir got to almost 1GB.


#!/bin/sh

## remove really old logs (180 days)
find /var/log/portage -name '*.log*' -mtime +180 -print0 | xargs --null --no-run-if-empty rm

## compress big logs (over 10 KB)
find /var/log/portage -name '*.log' -mtime +3 -size +10k -print0 | xargs --null --no-run-if-empty gzip

No comments:

Post a Comment