栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Centos / Linux设置logrotate为所有日志的最大文件大小

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Centos / Linux设置logrotate为所有日志的最大文件大小

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

size50M
一旦文件大小为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 5mail www@my.orgsize 100ksharedscriptspostrotate    /usr/bin/killall -HUP httpdendscript       }

这是文件

/var/log/httpd/access.log
和的说明
/var/log/httpd/error.log
。每当大小超过100k时,它们都会旋转一次,并且
www@my.org
经过5次旋转后会将旧日志文件邮寄(未压缩)到,而不是将其删除。这
sharedscripts
意味着该
postrotate
脚本将只运行一次(在压缩旧日志之后),而不是为每个循环日志运行一次。请注意,在本节的开头,第一个文件名周围的双引号允许logrotate旋转名称中带有空格的日志。会使用普通的shell引用规则,并带有
,
字符。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/383295.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号