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

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.



root #emerge --ask app-admin/logrotate



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

If you choose a different rotation, remember to move the /etc/cron.daily/logrotate script in the correct subdirectory, eg. under /etc/cron.weekly/ for a weekly rotation of logs.

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
    olddir /var/log/portage/old

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, highly configurable monitoring and logging daemon.