linux统计文件大小大于100k,Centos / Linux设置logrotate为所有日志的最大文件大小

小编典典

它指定要触发轮换的 日志文件 的大小。例如,size

50M一旦文件大小为50MB或更大,将触发日志轮换。您可以将后缀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时,它们都会旋转一次,并且www@my.org经过5次旋转后会将旧日志文件邮寄(未压缩)到,而不是将其删除。这sharedscripts意味着该postrotate脚本将只运行一次(在压缩旧日志之后),而不是为每个循环日志运行一次。请注意,在本节的开头,第一个文件名周围的双引号允许logrotate旋转名称中带有空格的日志。会使用普通的shell引用规则,并带有,和\字符。

2020-06-07

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值