Logrotate compress files as a different user than specified

logrotate

Using the following logrotate config file, rotated files are being chowned to the specified user but not compressed ones.

    /var/log/file.log {
           notifempty
            missingok
            size 1M
            rotate 30
            delaycompres
            create 0600 user group
            compress 
            }

Is this an expected behaviour from logrotate and if yes how can I tweak it to compress the logs with the correct permissions and user:group ?

Best Answer

'create' option tell logrotate to create new log file with specified permission before running postrotete script. It does not affect on permissions of compressed files. You may try this:

lastscript
chown user:group /var/log/yourapp/*.gz
chmod -R 0600 /var/log/yourapp/*.gz
endscript