加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-13 19:40:51 所属栏目:Linux 来源:网络整理
导读:我有一个应用程序每天生成一个非常重的大日志文件(每天约800MB),因此我需要压缩它们,但由于压缩需要时间,我希望在将HUP信号重新加载/发送到应用程序后,该logrotate压缩该文件. /var/log/myapp.log { rotate 7 size 500M compress weekly postrotate /bin/kil
我有一个应用程序每天生成一个非常重的大日志文件(每天约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选项将压缩推迟到下一轮.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读