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

Linux上的自由空间驱动的日志轮换?,第1张

概述有人刚问我’我们应该为我们的应用程序保留多长时间’,我的回答是“直到磁盘已满”,因为除了空间不足之外没有理由把它们扔掉. 但是,标准logrotate要求我们指定特定的周期轮数.是否有类似的东西让我们说“每天轮换,并保留尽可能多的历史,直到只有5%的空间免费”? 该平台是Redhat Linux. 您可以使用firstaction或lastaction指令来调用测试磁盘可用空间的shell脚本,然 有人刚问我’我们应该为我们的应用程序保留多长时间’,我的回答是“直到磁盘已满”,因为除了空间不足之外没有理由把它们扔掉.

但是,标准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上的自由空间驱动的日志轮换?全部内容,希望文章能够帮你解决Linux上的自由空间驱动的日志轮换?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1042586.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存