This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
Logrotate
Logrotate is a tool to periodically rotate (archive), delete, and optionally compress and/or mail historic log files. Logrotate ships with, and is invoked by a /etc/cron.daily cron job.
Installation
Emerge
root #
emerge --ask app-admin/logrotate
Configuration
Files
Accelerating log rotation can be very useful to setting up log rotate. Initial purging of extremely large logs, getting familiar with day to day messages, cleaning up the system, and setting up intrusion prevention systems can benefit greatly from this. Daily log rotation encourages administrators to be proactive about security, and system health rather than reactive.
- /etc/logrotate.conf - The daemon's configuration file.
- /etc/logrotate.d - This directory contains all log rotate settings and directives.
/etc/logrotate.conf
# rotate log files weekly #weekly daily
Portage log example
If the PORT_LOGDIR variable is set in /etc/portage/make.conf build logs will need to be rotated. The first line of the configuration file should hold the path where logs are stored by Portage:
/etc/logrotate.d/portage
/var/log/portage/*.log { su portage portage createolddir 755 portage portage rotate 1 weekly nocreate missingok ifempty olddir /var/log/portage/old compress }
To regularly delete logs add the line maxage N
to the config file, where N
is the number of days after which the log file will be deleted.