Skip to content

copytruncate,compress and default rotate value incompatibility #552

@vser1

Description

@vser1

With logrotate 3.21.0.61_cb99

The following configuration:

/var/log/foo.log
{
    copytruncate
    compress
}

Fails with

error: unable to open /var/log/foo.log.1 (read-only) for compression: No such file or directory

This is because rotateSingleLog calls copyTruncate with rotateCount=0 hence:

skip copying /var/log/foo.log to /var/log/foo.log.1

And in postrotateSingleLog we call compressLogFile which gives the earlier error.

Calling logrotate in debug does not check this (early return in compressLogFile).

I guess one could check that when giving copyTruncate and compress , rotate needs to be above 0.

Note that without compress, /var/log/foo.log is just truncated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions