在不设置转储的情况下,日志文件会越来越大,随着时间积累甚至会达到数G。这时候需要设置日志转储。logrotate会根据已有的配置文件,在文件的大小超过了规定值时,将当前的日志文件做压缩,同时删除最老的文件
新增/修改需要设置转储
logrotate的所有配置文件都在/etc/logrotate.d目录下
一个常见的文件格式:
"/var/log/syslog"
"/var/log/user.log"
{
# truncate file, do not delete & recreate
copytruncate
# compress rotated files with gzip
compress
# postpone compression to the next rotation
delaycompress
# ignore missing files
missingok
# do not rotate empty files
notifempty
# logrotate allows to use only year, month, day and unix epoch
da