라즈베리파이 nginx 로그의 주기를 설정하기

서버에 설치된 데몬마다 로그를 생성하는데, 각 데몬별로 로그 주기를 정할 수 있는 곳이
/etc/logrotate.d이다.

1
2
$ cd /etc/logrotate.d
$ vi nginx

이중 nginx를 vi 에디터로 열어서 다음과 같이 수정하자.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#/var/log/nginx/*.log {
# weekly
# missingok
# rotate 52
# compress
# delaycompress
# notifempty
# create 0640 www-data adm
# sharedscripts
# prerotate
# if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
# run-parts /etc/logrotate.d/httpd-prerotate; \
# fi \
# endscript
# postrotate
# invoke-rc.d nginx rotate >/dev/null 2>&1
# endscript
#}

/var/log/nginx/*.log {
daily
rotate 365
copytruncate
delaycompress
compress
dateext
notifempty
missingok
}

테스트

1
2
$ logrotate —force /etc/logrotate.d/nginx
$ cd /var/log/nginx

nginx 웹서버를 실행 후 생성되는 로그를 확인해보자.
로그 경로는 nginx 설정에 있다.