System information

Analyzing and Managing System Log Files 65
logrotate is usually run as a daily cron job. It does not modify any log files more
than once a day unless the log is to be modified because of its size, because logro-
tate is being run multiple times a day, or the --force option is used.
The main configuration file of logrotate is /etc/logrotate.conf. System
packages as well as programs that produce log files (for example, apache2) put their
own configuration files in the /etc/logrotate.d/ directory. The content of /
etc/logrotate.d/ is included via /etc/logrotate.conf.
Example4.1: Example for /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# comment these to switch compression to use gzip or another
# compression scheme
compresscmd /usr/bin/bzip2
uncompresscmd /usr/bin/bunzip2
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
IMPORTANT
The create option pays heed to the modes and ownerships of files spec-
ified in /etc/permissions*. If you modify these settings, make sure no
conflicts arise.
logrotate is controlled through cron and is called daily by /etc/
cron.daily/logrotate. Use /var/lib/logrotate.status to find out
when a particular file has been rotated lastly.