logrotate compress files after the postrotate script

Posted by Thomas on Stack Overflow See other posts from Stack Overflow or by Thomas
Published on 2011-09-01T14:39:45Z Indexed on 2011/11/12 1:50 UTC
Read the original article Hit count: 242

Filed under:
|
|
|
|

I have an application generating a really heavy big log file every days (~800MB a day), thus I need to compress them but since the compression takes time, I want that logrotate compress the file after reloading/sending HUP signal to the application.

/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
}

Is it already the case that the compression takes place after the postrotate (which would be counter-intuitive)? If not Can anyone tell me if it's possible to do that without an extra command script (an option or some trick)?

Thanks Thomas

© Stack Overflow or respective owner

Related posts about linux

Related posts about shell