2008.05.19 20:33
roglotate 라는 패키지를 이용하여 로그를 관리하는 방법에 대하여 알아봅니다.
1. 먼저 패키지가 설치되어 있는지 확인합니다.
2. 설정파일은 /etc/logrotate.conf 입니다. 일반적으로 아래와 같이 되어있습니다.
[root@sakang logrotate.d]# vi /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
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
~
위 설정파일을 보면 /etc/logrotate.d 를 include 하고 있습니다.
또한 매주 4번 순환합니다.
3. 아파치 로그파일이 어떻게 순환되고 있는지 살펴보겠습니다.
[root@sakang log]# vi /etc/logrotate.d/apache
/usr/local/apache/logs/access_log {
compress
weekly
postrotate
/usr/bin/killall -HUP httpd
endscript
}
/usr/local/apache/logs/error_log {
compress
missingok
postrotate
/usr/bin/killall -HUP httpd
endscript
}
compress --> 순환되어진 파일을 압축합니다.
weekly --> 매주 rotate 합니다. weekly 외에 daily 와 monthly 도 있습니다.
로테이트 후 postrotate 와 endscript 사이에 있는 명령(/usr/bin/killall -HUP httpd)을 실행합니다.
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
106 | rsync / 파티션 전체 동기화 방법 | 호스트웨이 | 2012.12.14 | 2429 |
105 | 특정 파일이 소속된 rpm 패키지 찾기 | 호스트웨이 | 2012.12.14 | 1783 |
104 | df 와 du의 출력 크기가 다르게 보이는 이유 | 호스트웨이 | 2012.12.14 | 4436 |
103 | nl명령어를 사용해 파일내용 출력시 행번호 붙이기 | 호스트웨이 | 2012.12.20 | 3967 |
102 | df 쉽게 보기 | 호스트웨이 | 2012.12.20 | 2835 |
101 | 쉘 프롬프트에서 바로 이전 디렉토리로 이동하기 | 호스트웨이 | 2012.12.20 | 2751 |
100 | free -m 에서 free (남는 메모리 양) 최소량 제한하기 | 호스트웨이 | 2012.12.21 | 2149 |
99 | [ERROR] ftp error 500 OOPS: cannot change directory:/home/ | 호스트웨이 | 2012.12.21 | 4308 |
98 | 리눅스 캐시 메모리 비우기 | 호스트웨이 | 2012.12.26 | 5269 |
97 | 리눅스 free 명령어 | 호스트웨이 | 2012.12.26 | 1819 |
96 | ls -l 출력 시 날짜형태 변경 | 호스트웨이 | 2012.12.27 | 6164 |
95 | 리눅스 uniq 명령어 | 호스트웨이 | 2012.12.27 | 7880 |
94 | sftp 서비스 막기 | 호스트웨이 | 2012.12.27 | 1321 |
93 | 오늘 생성한 파일만 조회하기 | 호스트웨이 | 2012.12.27 | 6267 |
92 | partprobe - 리부팅 없이 사용 중인 파티션 재인식 | 호스트웨이 | 2012.12.28 | 8371 |
91 | samba 설치 | 호스트웨이 | 2014.04.14 | 3381 |
90 | 리눅스 커널 업데이트 및 커널 변경 부팅 방법 | 호스트웨이 | 2014.10.30 | 23460 |
89 | SVN(subversion) 설치 및 셋팅 | 호스트웨이 | 2014.12.02 | 6426 |
88 | epel-release 설치하기 | 호스트웨이 | 2014.12.22 | 14299 |
87 | ngrinder를 이용한 부하 테스트 - 1) Controller 설치 | 호스트웨이 | 2015.04.08 | 4287 |