Logrotate
介绍
常用配置文件
/etc/logrotate.conf 文件配置
# see "man logrotate" for details
# rotate log files weekly
weekly #默认每周执行一次日志轮询
# keep 4 weeks worth of backlogs
rotate 4 #默认保留4个日志文件, 0 是没有备份
# create new (empty) log files after rotating old ones
create #自动创建新的日志文件,新的文件和原来的文件具有相同的权限
# use date as a suffix of the rotated file
dateext #切割后的日志文件以当前日期为结尾,如xxx.log-20180810,如果注释掉,切割出来是按数字递增,即 xxx.log-1这种格式
# uncomment this if you want your log files compressed
#compress 是否通过gzip压缩转储以后的日志文件,如xxx.log-20180810.gz;如果希望日志文件压缩,请取消注释
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d #将logrotate.d目录里的文件加载进来
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly #每个月切割一次,取代默认的一周
create 0664 root utmp #新建日志权限为0664,属主为root,属组为utmp
minsize 1M #文件大小超过1M后才会切割
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}参数介绍
使用过的例子
最后更新于