Logrotate

From Gentoo Wiki
Jump to: navigation, search
This article is a stub. You can help by expanding it.
Resources

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.
FILE /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:

FILE /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.

See also

  • Sysklogd - A simple, generic logging daemon.
  • Syslog-ng - A powerful, massively configurable monitoring and logging daemon.