Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   logrotate.conf    ( 5 )

logrotate в вращает, сжимает и отправляет системные журналы по почте (logrotate ‐ rotates, compresses, and mails system logs)

Конфигурационный файл (Config file)

logrotate reads everything about the log files it should be
       handling from the series of configuration files specified on the
       command line.  Each configuration file can set global options
       (local definitions override global ones, and later definitions
       override earlier ones) and specify logfiles to rotate.  Global
       options do not affect preceding include directives.  A simple
       configuration file looks like this:

# sample logrotate configuration file compress

/var/log/messages { rotate 5 weekly postrotate /usr/bin/killall -HUP syslogd endscript }

"/var/log/httpd/access.log" /var/log/httpd/error.log { rotate 5 mail recipient@example.org size 100k sharedscripts postrotate /usr/bin/killall -HUP httpd endscript }

/var/log/news/* { monthly rotate 2 olddir /var/log/news/old missingok sharedscripts postrotate kill -HUP $(cat /var/run/inn.pid) endscript nocompress }

~/log/*.log {}

The first few lines set global options; in the example, logs are compressed after they are rotated. Note that comments may appear anywhere in the config file as long as the first non-whitespace character on the line is a #.

Values are separated from directives by whitespace and/or an optional =. Numbers must be specified in a format understood by strtoul(3).

The next section of the config file defines how to handle the log file /var/log/messages. The log will go through five weekly rotations before being removed. After the log file has been rotated (but before the old version of the log has been compressed), the command /usr/bin/killall -HUP syslogd will be executed.

The next section defines the parameters for both /var/log/httpd/access.log and /var/log/httpd/error.log. Each is rotated whenever it grows over 100 kilobytes in size, and the old logs files are mailed (uncompressed) to recipient@example.org after going through 5 rotations, rather than being removed. The sharedscripts means that the postrotate script will only be run once (after the old logs have been compressed), not once for each log which is rotated. Note that log file names may be enclosed in quotes (and that quotes are required if the name contains spaces). Normal shell quoting rules apply, with ', ", and \ characters supported.

The next section defines the parameters for all of the files in /var/log/news. Each file is rotated on a monthly basis.

The last section uses tilde expansion to rotate log files in the home directory of the current user. This is only available, if your glob library supports tilde expansion. GNU glob does support this.

Please use wildcards with caution. If you specify *, logrotate will rotate all files, including previously rotated ones. A way around this is to use the olddir directive or a more exact wildcard (such as *.log).

Here is more information on the directives which may be included in a logrotate configuration file: