Redhat 7에서는 logrotate 압축이 전혀 작동하지 않습니다.

Redhat 7에서는 logrotate 압축이 전혀 작동하지 않습니다.

내 logrotate 압축이 전혀 작동하지 않습니다. 로그 회전은 파일을 회전하지만 전혀 압축하지는 않습니다. 내가 저지른 간단한 실수를 알려주십시오. 이것은 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

이것은 내 conf 파일 logrotate.conf입니다.

# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

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

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

# 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 {
    monthly
    create 0664 root utmp
        minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

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

/tmp/app/stderr {
     missingok
     rotate 1
     daily
     size 400M
     compress
     su
}

답변1

delaycompress구성 섹션에 추가하면 /var/log/문제가 해결되었습니다.

에서 man logrotate:

delaycompress

      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.

흥미롭게도 내 원래 구성( directives 제외 delaycompress)은 다음에서 직접 제공됩니다 man logrotate( weekly로 변경한 경우 제외 daily).

# sample logrotate configuration file
compress

/var/log/messages {
     rotate 5
     weekly
     postrotate
         /usr/bin/killall -HUP syslogd
     endscript
 }

관련 정보