Linux上的自由空间驱动的日志轮换?

有人刚问我’我们应该为我们的应用程序保留多长时间’,我的回答是“直到磁盘已满”,因为除了空间不足之外没有理由把它们扔掉.

但是,标准logrotate要求我们指定特定的周期轮数.是否有类似的东西让我们说“每天轮换,并保留尽可能多的历史,直到只有5%的空间免费”?

该平台是Redhat Linux.

解决方法

您可以使用firstaction或lastaction指令来调用测试磁盘可用空间的shell脚本,然后对最旧的文件执行删除操作.
firstaction/endscript
          The lines between firstaction and endscript (both of which must appear on lines by themselves) are
          executed (using /bin/sh) once before all log files that match the wildcarded pattern are  rotated,before  prerotate  script  is  run  and  only if at least one log will actually be rotated.  These
          directives may only appear inside a log file deFinition. Whole pattern is passed to the script  as
          first  argument.  If  the script exits with error,no further processing is done. See also lastac-
          tion.

更新:

这是关于您可以运行的脚本类型的Stackoverflow帖子:

https://stackoverflow.com/questions/7523059/remove-oldest-file-in-repository

相关文章

Linux中的ARP防火墙主要用于防御ARP欺骗攻击,其效果取决于多...
insmod和modprobe加-f参数导致Invalid module format错误 这...
将ArchLinux安装到U盘 几个月前入门Arch的时候上网搜了不少安...
1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...