postrotate脚本后的linux – logrotate压缩文件

postrotate脚本后的linux – logrotate压缩文件,第1张

概述我有一个应用程序每天生成一个非常重的大日志文件(每天约800MB),因此我需要压缩它们,但由于压缩需要时间,我希望在将HUP信号重新加载/发送到应用程序后,该logrotate压缩该文件. /var/log/myapp.log { rotate 7 size 500M compress weekly postrotate /bin/kill 我有一个应用程序每天生成一个非常重的大日志文件(每天约800MB),因此我需要压缩它们,但由于压缩需要时间,我希望在将HUP信号重新加载/发送到应用程序后,该logrotate压缩该文件.
/var/log/myapp.log {    rotate 7    size 500M    compress    weekly    postrotate        /bin/kill -HUP `cat /var/run/myapp.pID 2>/dev/null` 2>/dev/null || true    endscript}

压缩发生在后旋后(已经是反直觉的)了吗?
如果没有任何人可以告诉我,如果可以这样做没有额外的命令脚本(一个选项或一些技巧)?

谢谢
托马斯

解决方法 后转脚本在压缩发生之前运行:从 logrotate的手册页

The next section of the config files defined how to handle the log file
/var/log/messages. The log will go through five weekly rotations before
being removed. After the log file has been rotated (but before the old
version of the log has been compressed),the command /sbin/killall -HUP
syslogd will be executed.

无论如何,您可以使用delaycompress选项将压缩推迟到下一轮.

总结

以上是内存溢出为你收集整理的postrotate脚本后的linux – logrotate压缩文件全部内容,希望文章能够帮你解决postrotate脚本后的linux – logrotate压缩文件所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存