Logrotate는 말하는 동안 로그를 회전시키지 않습니다.


1

갑자기 작동하지 않을 때까지 정상적으로 작동하는 logrotate 구성이 있습니다. log응용 프로그램을 업데이트하는 동안 폴더를 삭제하고 다시 만든 후에 로그 회전이 중지 된 것 같습니다 . 다음은 config 및 logrotate 로그의 관련 부분입니다.

/etc/logrotate.conf

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

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

# uncomment this if you want your log files compressed
#compress

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

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

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

# system-specific logs may be configured here
/var/lib/redmine/log/production.log{
    daily
    rotate 30
    compress
    delaycompress
    missingok
    notifempty
}

logrotate를 수동으로 실행 한 후 :

rotating pattern: /var/lib/redmine/log/production.log after 1 days (30 rotations)
empty log files are not rotated, old logs are removed
considering log /var/lib/redmine/log/production.log
  log needs rotating
rotating log /var/lib/redmine/log/production.log, log->rotateCount is 30
dateext suffix '-20151209'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
renaming /var/lib/redmine/log/production.log.30.gz to /var/lib/redmine/log/production.log.31.gz (rotatecount 30, logstart 1, i 30),
renaming /var/lib/redmine/log/production.log.29.gz to /var/lib/redmine/log/production.log.30.gz (rotatecount 30, logstart 1, i 29),
renaming /var/lib/redmine/log/production.log.28.gz to /var/lib/redmine/log/production.log.29.gz (rotatecount 30, logstart 1, i 28),
renaming /var/lib/redmine/log/production.log.27.gz to /var/lib/redmine/log/production.log.28.gz (rotatecount 30, logstart 1, i 27),
renaming /var/lib/redmine/log/production.log.26.gz to /var/lib/redmine/log/production.log.27.gz (rotatecount 30, logstart 1, i 26),
renaming /var/lib/redmine/log/production.log.25.gz to /var/lib/redmine/log/production.log.26.gz (rotatecount 30, logstart 1, i 25),
renaming /var/lib/redmine/log/production.log.24.gz to /var/lib/redmine/log/production.log.25.gz (rotatecount 30, logstart 1, i 24),
renaming /var/lib/redmine/log/production.log.23.gz to /var/lib/redmine/log/production.log.24.gz (rotatecount 30, logstart 1, i 23),
renaming /var/lib/redmine/log/production.log.22.gz to /var/lib/redmine/log/production.log.23.gz (rotatecount 30, logstart 1, i 22),
renaming /var/lib/redmine/log/production.log.21.gz to /var/lib/redmine/log/production.log.22.gz (rotatecount 30, logstart 1, i 21),
renaming /var/lib/redmine/log/production.log.20.gz to /var/lib/redmine/log/production.log.21.gz (rotatecount 30, logstart 1, i 20),
renaming /var/lib/redmine/log/production.log.19.gz to /var/lib/redmine/log/production.log.20.gz (rotatecount 30, logstart 1, i 19),
renaming /var/lib/redmine/log/production.log.18.gz to /var/lib/redmine/log/production.log.19.gz (rotatecount 30, logstart 1, i 18),
renaming /var/lib/redmine/log/production.log.17.gz to /var/lib/redmine/log/production.log.18.gz (rotatecount 30, logstart 1, i 17),
renaming /var/lib/redmine/log/production.log.16.gz to /var/lib/redmine/log/production.log.17.gz (rotatecount 30, logstart 1, i 16),
renaming /var/lib/redmine/log/production.log.15.gz to /var/lib/redmine/log/production.log.16.gz (rotatecount 30, logstart 1, i 15),
renaming /var/lib/redmine/log/production.log.14.gz to /var/lib/redmine/log/production.log.15.gz (rotatecount 30, logstart 1, i 14),
renaming /var/lib/redmine/log/production.log.13.gz to /var/lib/redmine/log/production.log.14.gz (rotatecount 30, logstart 1, i 13),
renaming /var/lib/redmine/log/production.log.12.gz to /var/lib/redmine/log/production.log.13.gz (rotatecount 30, logstart 1, i 12),
renaming /var/lib/redmine/log/production.log.11.gz to /var/lib/redmine/log/production.log.12.gz (rotatecount 30, logstart 1, i 11),
renaming /var/lib/redmine/log/production.log.10.gz to /var/lib/redmine/log/production.log.11.gz (rotatecount 30, logstart 1, i 10),
renaming /var/lib/redmine/log/production.log.9.gz to /var/lib/redmine/log/production.log.10.gz (rotatecount 30, logstart 1, i 9),
renaming /var/lib/redmine/log/production.log.8.gz to /var/lib/redmine/log/production.log.9.gz (rotatecount 30, logstart 1, i 8),
renaming /var/lib/redmine/log/production.log.7.gz to /var/lib/redmine/log/production.log.8.gz (rotatecount 30, logstart 1, i 7),
renaming /var/lib/redmine/log/production.log.6.gz to /var/lib/redmine/log/production.log.7.gz (rotatecount 30, logstart 1, i 6),
renaming /var/lib/redmine/log/production.log.5.gz to /var/lib/redmine/log/production.log.6.gz (rotatecount 30, logstart 1, i 5),
renaming /var/lib/redmine/log/production.log.4.gz to /var/lib/redmine/log/production.log.5.gz (rotatecount 30, logstart 1, i 4),
renaming /var/lib/redmine/log/production.log.3.gz to /var/lib/redmine/log/production.log.4.gz (rotatecount 30, logstart 1, i 3),
renaming /var/lib/redmine/log/production.log.2.gz to /var/lib/redmine/log/production.log.3.gz (rotatecount 30, logstart 1, i 2),
renaming /var/lib/redmine/log/production.log.1.gz to /var/lib/redmine/log/production.log.2.gz (rotatecount 30, logstart 1, i 1),
renaming /var/lib/redmine/log/production.log.0.gz to /var/lib/redmine/log/production.log.1.gz (rotatecount 30, logstart 1, i 0),
renaming /var/lib/redmine/log/production.log to /var/lib/redmine/log/production.log.1
creating new /var/lib/redmine/log/production.log mode = 0644 uid = 1000 gid = 1000
removing old log /var/lib/redmine/log/production.log.31.gz
error: error opening /var/lib/redmine/log/production.log.31.gz: No such file or directory

로그 디렉토리를 나열한 후 :

ll /var/lib/redmine/log/
total 178484
drwxrwxr-x  2 redmine redmine      4096 Dec  9 12:05 ./
drwxr-xr-x 20 redmine redmine      4096 Dec  6 23:56 ../
-rw-rw-r--  1 redmine redmine     49581 Dec  8 14:47 development.log
-rw-r--r--  1 redmine redmine 182700709 Dec  9 12:05 production.log

따라서 로그 파일을 회전 시켰지만 실제로는 아무 일도 일어나지 않았습니다. 그 이유는 무엇입니까?

답변:


1

한 가지 이유는 logrotate가 루트로 작동하는 동안 redmine 사용자처럼 로그를 나열하기 때문에 디렉토리 목록에 표시되지 않기 때문일 수 있습니다.

차라리 다음 내용으로 /etc/logrotate.d/redmine 파일을 만들고 싶습니다.

/path/to/your/redmine/log/production.log {
daily
missingok
rotate 31
compress
delaycompress
notifempty
copytruncate
} 

그런 다음 테스트하십시오.

sudo /usr/sbin/logrotate -f /etc/logrotate.d/redmine

글쎄, 이것은 이유가 아니었지만 마침내 그것을 식별하는 데 도움이되었습니다. log폴더 에 대한 권한이 잘못되었습니다 . 나는 -w그것에 대한 그룹 액세스 권한이 있었다. 후 chmod 755모두 작동하기 시작했다.
svz

0

문제가 log폴더 에 대한 잘못된 권한으로 바뀌 었습니다 . Logrotate는 그룹 쓰기 액세스 권한을 유발하지 않으므로 처리하지 않습니다. chmod 755로그 폴더에서 실행 한 후에 는 모두 작동하기 시작했습니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.