Logrotate 설치, 두 서버 간에 nginx 설정이 중복되었지만 로그 파일 크기가 다름

Logrotate 설치, 두 서버 간에 nginx 설정이 중복되었지만 로그 파일 크기가 다름

nginx를 사용하는 두 개의 웹 서버가 있고 두 서버 모두에 logrotate가 설치되어 있으며 logrotate.conf와 logrotate.d/nginx의 설정은 모두 동일합니다.

둘 다 로그를 /home/websitename/.pm2/logs에 저장합니다.

첫 번째 웹 서버에서 로그는 다음과 같이 구성됩니다.

-rw-r--r--. 1 website website   11M Feb 27 13:21 example.com-out-2__2018-02-27_13-21-12.log
-rw-r--r--. 1 website website   11M Feb 27 13:46 example.com-out-2__2018-02-27_13-46-12.log
-rw-r--r--. 1 website website   11M Feb 27 14:00 example.com-out-2__2018-02-27_14-00-12.log
-rw-r--r--. 1 website website   11M Feb 27 14:19 example.com-out-2__2018-02-27_14-19-42.log
-rw-r--r--. 1 website website   11M Feb 27 14:42 example.com-out-2__2018-02-27_14-42-42.log
-rw-r--r--. 1 website website   11M Feb 27 15:09 example.com-out-2__2018-02-27_15-09-12.log
-rw-r--r--. 1 website website   11M Feb 27 15:36 example.com-out-2__2018-02-27_15-36-12.log
-rw-r--r--. 1 website website   11M Feb 27 16:00 example.com-out-2__2018-02-27_16-00-42.log
-rw-r--r--. 1 website website   11M Feb 27 16:24 example.com-out-2__2018-02-27_16-24-42.log
-rw-r--r--. 1 website website   11M Feb 27 16:48 example.com-out-2__2018-02-27_16-48-12.log

보시다시피 그것들은 모두 특정 파일 크기, 하루에 여러 개의 로그 파일 등입니다.

두 번째 웹 서버에서는 단일 대형 파일에 대한 로깅이 이루어집니다. 동일한 /home/websitename/.pm2/logs 위치에 있습니다.

-rw-rw-r--. 1 website website  19G Mar  9 14:04 example.com-error-0.log
-rw-rw-r--. 1 website website 7.2G Mar  7 06:09 example.com-error-1.log
-rw-rw-r--. 1 website website 5.2G Mar  9 14:04 example.com-out-0.log
-rw-rw-r--. 1 website website 1.2G Feb 23 23:15 example.com-out-1.log

생각하다error-0 및 error-1 로그의 원인은 서버가 재부팅되고 새 로그가 시작되었기 때문입니다.

질문은 하나의 19GB 유형 파일에 이 괴물이 아닌 더 작은 파일을 생성하도록 로깅을 어떻게 변경합니까?

모든 설정을 살펴봤지만 알 수 없는 것 같습니다! 나는 logrotate.status를 확인할 때 현재 상태를 얻으므로 logrotate가 작동하고 있다고 "생각합니다".

/etc/logrotate.conf:

이것은 /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
# 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
}

/etc/logrotate.d/nginx 파일:

/var/log/nginx/*.log {
        daily
        missingok
        rotate 4
        compress
        delaycompress
        notifempty
        create 640 nginx adm
        sharedscripts
        postrotate
                if [ -f /var/run/nginx.pid ]; then
                        kill -USR1 `cat /var/run/nginx.pid`
                fi
        endscript
}

관련 정보