Linux ETC

로그 관리

2008.05.19 20:33

호스트웨이 조회 수:24801

 roglotate 라는 패키지를 이용하여 로그를 관리하는 방법에 대하여 알아봅니다.

1. 먼저 패키지가 설치되어 있는지 확인합니다. 

[root@sakang root]# rpm -qa | grep logrotate
logrotate-3.6.4-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)을 실행합니다.

번호 제목 글쓴이 날짜 조회 수
306 리눅스 커널 버전 의미 file 호스트웨이 2012.04.20 27086
305 debian 에서 CSR decoding 시에 발생되는 에러(40 The CSR uses a key that is believed to have been compromised!) HOSTWAY 2008.12.04 27055
304 원하는 용량만큼 분할해서 압축하기 sylee 2008.05.15 27049
303 diff 사용방법 sylee 2008.05.15 26967
302 가용할 수 있는 물리적 메모리를 최대한 이용해봅시다. hostway 2008.05.14 26669
301 부하 테스트 2편 – Web Test 호스트웨이 2012.04.27 26658
300 sudo 사용하기 호스트웨이 2008.05.19 26558
299 at 으로 작업 예약 하기 호스트웨이 2008.05.19 26293
298 리눅스 ls 디렉토리 혹은 파일 별 출력하기 file 호스트웨이 2012.06.22 26079
297 find 명령 1 sylee 2008.05.14 25983
296 mrtg를 이용한 시스템자원 모니터링(debian 5.0) jook 2009.06.02 25916
295 watch 로 시스템 모니터링 하기 호스트웨이 2008.05.19 25533
294 XFS파일 장점및 단점 호스트웨이 2012.07.06 25465
293 ipv6 비활성화 하기 호스트웨이 2012.04.06 25457
292 XFS 파티션 설치 및 마운트 (CentOS 기준) 호스트웨이 2015.09.09 25348
291 vsftp에서 업로드, 다운로드 전송속도 제한하기 file 호스트웨이 2012.05.05 25275
290 CPU core 별 사용량 확인 하기 호스트웨이 2012.06.08 25265
289 rsync를 사용하여 데이터 백업 하기 jook 2009.04.25 25179
288 ncftp의 bookmark 기능 sylee 2008.05.15 25075
287 비프음 콘트롤 호스트웨이 2009.02.12 24943