它指定要触发轮换的日志文件的大小。 例如,一旦文件大小为50MB或更大,大小size 50M就会触发日志轮换。 您可以将后缀M表示兆字节,将k表示千字节,将G表示千兆字节。 如果不使用后缀,则将其表示为字节。 您可以在最后检查示例。 有三个指令可用size , maxsize和minsize 。 根据手册页 :
minsize size
Log files are rotated when they grow bigger than size bytes,
but not before the additionally specified time interval (daily,
weekly, monthly, or yearly). The related size option is simi-
lar except that it is mutually exclusive with the time interval
options, and it causes log files to be rotated without regard
for the last rotation time. When minsize is used, both the
size and timestamp of a log file are considered.
size size
Log files are rotated only if they grow bigger then size bytes.
If size is followed by k, the size is assumed to be in kilo-
bytes. If the M is used, the size is in megabytes, and if G is
used, the size is in gigabytes. So size 100, size 100k, size
100M and size 100G are all valid.
maxsize size
Log files are rotated when they grow bigger than size bytes even before
the additionally specified time interval (daily, weekly, monthly,
or yearly). The related size option is similar except that it
is mutually exclusive with the time interval options, and it causes
log files to be rotated without regard for the last rotation time.
When maxsize is used, both the size and timestamp of a log file are
considered.
这是一个例子:
"/var/log/httpd/access.log" /var/log/httpd/error.log {
rotate 5
mail www@my.org
size 100k
sharedscripts
postrotate
/usr/bin/killall -HUP httpd
endscript
}
这是文件/var/log/httpd/access.log和/var/log/httpd/error.log 。 只要大小超过100k,它们就会旋转一次,并且经过5次旋转后,旧日志文件会被邮寄(未压缩)到www@my.org ,而不是被删除。 该sharedscripts指postrotate脚本将只一次被旋转每个日志运行(旧日志已被压缩后),一次也没有。 请注意,在本节的开头,第一个文件名周围的双引号允许logrotate旋转名称中带有空格的日志。 普通的shell引用规则,用,和\\支持的字符。