3、关于日志轮循相关内容,linux中的日志轮循是使用logrotate
# 查看logrotate相关配置文件
[root@bogon ~]# rpm -ql logrotate
/etc/cron.daily/logrotate
/etc/logrotate.conf
/etc/logrotate.d
/usr/sbin/logrotate
/usr/share/doc/logrotate-3.7.8
/usr/share/doc/logrotate-3.7.8/CHANGES
/usr/share/doc/logrotate-3.7.8/COPYING
/usr/share/man/man5/logrotate.conf.5.gz
/usr/share/man/man8/logrotate.8.gz
/var/lib/logrotate.status
# 编缉logrotate配置文件
vim /etc/logrotate.conf
[root@bogon ~]# cat /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
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# 以周为单位轮循,4次:messages1.....messages4 massages1.....massages4......,往前覆盖
/var/log/messages {
weekly
rotate 4
dateext
compress
missingok
create 644 root root
postrotate
/usr/bin/killall -HUP rsyslogd #平滑重启rsyslog或者使用/var/run/syslogd.pid更准确
endscript
}
# system-specific logs may be also be configured here.
# 以时间为结尾,如下:

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-02/140240.htm
