My logrotate compress is not working at all. Log rotation will rotate file but it doesn't compress at all. Any simple mistake i am doing please let me know. This is output of logrotate -v /etc/logrotate.conf

rotating pattern: /var/log/btmp  monthly (1 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/btmp
  log does not need rotating

rotating pattern: /tmp/app/stderr  419430400 bytes (1 rotations)
empty log files are not rotated, old logs are removed
considering log /tmp/app/stderr
  log needs rotating
rotating log /tmp/app/stderr, log->rotateCount is 1
dateext suffix '-20160603'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
glob finding old rotated logs failed
fscreate context set to unconfined_u:object_r:user_tmp_t:s0
renaming /tmp/app/stderr to /tmp/app/stderr-20160603
creating new /tmp/app/stderr mode = 0755 uid = 0 gid = 0
set default create context
[root@localhost app]# ls -l 
total 2103448

And here is my conf file logrotate.conf

# rotate log files weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones

# use date as a suffix of the rotated file
# uncomment this if you want your log files compressed

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    create 0664 root utmp
        minsize 1M
    rotate 1

/var/log/btmp {
    create 0600 root utmp
    rotate 1

# system-specific logs may be also be configured here.

/tmp/app/stderr {
     rotate 1
     size 400M
  • Issue is compress is not working at all in my case. – Ravi Jun 3 '16 at 17:30
  • I have already attached output of -v which is equivlant to -d option -d Turns on debug mode and implies -v. In debug mode, no changes will be made to the logs or to the logrotate state file. – Ravi Jun 3 '16 at 19:31
  • unlikely, but perhaps you dont have gzip installed? – meuh Jun 3 '16 at 19:51
  • This is output of "which gzip" command /usr/bin/gzip so that means gzip is installed. – Ravi Jun 4 '16 at 2:25
  • +1 I see the same thing happening on CentOS7 – Florian Heigl Jan 5 '17 at 9:36

Adding delaycompress to the configuration section for /var/log/ will solve the problem.

From man logrotate:


      Postpone  compression of the previous log file to the next rota‐
      tion cycle.  This only has effect when used in combination  with
      compress.   It  can  be used when some program cannot be told to
      close its logfile and thus might continue writing to the  previ‐
      ous log file for some time.

Interestingly, the original configuration I had (without the delaycompress directive), came straight out of man logrotate (except I changed weekly to daily):

# sample logrotate configuration file

/var/log/messages {
     rotate 5
         /usr/bin/killall -HUP syslogd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.