您查看的文章来源于http://www.oklinux.cn
主要的配置文件。当 logrotate 从logrotate.conf 读到include 选项时,会从指定文件读入配置信息,就好像他们已经在/etc/logrotate.conf 中一样。
第13行 include /etc/logrotate.d 告诉 logrotate 读入存放在/etc/logrotate.d 目录中的日志转储参数,当系统中安装了RPM 软件包时,使用include 选项十分有用。RPM 软件包的日志转储参数一般存放在/etc/logrotate.d 目录。
include 选项十分重要,一些应用把日志转储参数存放在 /etc/logrotate.d 。
典型的应用有:apache, linuxconf, samba, cron 以及syslog。
这样,系统管理员只要管理一个 /etc/logrotate.conf 文件就可以了。
四、使用include 选项覆盖缺省配置
当 /etc/logrotate.conf 读入文件时,include 指定的文件中的转储参数将覆盖缺省的参数,如下例:
# linuxconf 的参数
/var/log/htmlaccess.log
{ errors jim
notifempty
nocompress
weekly
prerotate
/usr/bin/chattr -a /var/log/htmlaccess.log
endscript
postrotate
/usr/bin/chattr +a /var/log/htmlaccess.log
endscript
}
/var/log/netconf.log
{ nocompress
monthly
}
在这个例子中,当 /etc/logrotate.d/linuxconf 文件被读入时,下面的参数将覆盖/etc/logrotate.conf中缺省的参数。
Notifempty
errors jim
五、为指定的文件配置转储参数
经常需要为指定文件配置参数,一个常见的例子就是每月转储/var/log/wtmp。为特定文件而使用的参数格式是:
# 注释
/full/path/to/file
{
option(s)
}
下面的例子就是每月转储 /var/log/wtmp 一次:
#Use logrotate to rotate wtmp