On Thu, 27 Jan 2011 12:34:44 +0000 Paul Martin <p...@debian.org> wrote:
> Have you got a logrotate.conf script that exhibits this behaviour?
>
> From my reading of the source code, there should not be any change in
> this behaviour between versions.
>
> My suspicion is that you have "delaycompress" set:

We've just been confused by this as well. Attached is a sample conf file. From logrotate 3.8.1, Debian 7.6, running with -d -f:

        reading config file logrotate_order_test.conf

        Handling 1 logs

rotating pattern: /var/log/foo.log forced from command line (no old logs will be kept)
        empty log files are rotated, old logs are removed
        considering log /var/log/foo.log
          log needs rotating
        rotating log /var/log/foo.log, log->rotateCount is 0
        dateext suffix '-20141104'
        glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /var/log/foo.log.1.gz to /var/log/foo.log.2.gz (rotatecount 1, logstart 1, i 1), renaming /var/log/foo.log.0.gz to /var/log/foo.log.1.gz (rotatecount 1, logstart 1, i 0),
        renaming /var/log/foo.log to /var/log/foo.log.1
        disposeName will be /var/log/foo.log.1.gz
        running postrotate script
        running script (multiple) with arg /var/log/foo.log : "
                echo "Running postrotate script..."
                ls /var/log/foo.log*
                echo "Finished postrotate script"
        "
        compressing log with: /bin/gzip
        removing old log /var/log/foo.log.1.gz
error: error opening /var/log/foo.log.1.gz: No such file or directory

Compression is definitely happening after the postrotate script is run.

Looking at the source, it looks like compressLogFile() is getting called in postrotateSingleLog() (logrotate.c, line 1455) if 'compress' is set and 'delaycompress' isn't set:

        if ((log->flags & LOG_FLAG_COMPRESS) &&
            !(log->flags & LOG_FLAG_DELAYCOMPRESS)) {
hasErrors = compressLogFile(rotNames->finalName, log, &state->sb);
        }

compressLogFile() only gets called in prerotateSingleLog() if both 'compress' and 'delaycompress' are set: (line 1006)

        if (log->flags & LOG_FLAG_COMPRESS &&
            log->flags & LOG_FLAG_DELAYCOMPRESS) {
        ...
hasErrors = compressLogFile(oldName, log, &sbprev);
        ...
                    hasErrors = compressLogFile(oldName, log, &sbprev);
        ...
        }

--
Matthew Rahtz, Informatics Systems Group
The Wellcome Trust Sanger Institute, Hinxton, Cambridge, CB10 1HH, UK



--
The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
/var/log/foo.log {
    compress
    sharedscripts
    postrotate
        echo "Running postrotate script..."
        ls /var/log/foo.log*
        echo "Finished postrotate script"
    endscript
}

Reply via email to