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 linux 특정 용량으로 파일을 찾기, 삭제하기 호스트웨이 2015.09.08 4682
305 리눅스 tee명령어를 이용하여 디렉토리 목록 저장 file 호스트웨이 2012.09.28 4730
304 라우팅 제어명령 호스트웨이 2015.09.17 4784
303 리눅스 명령어 모음 호스트웨이 2012.12.06 4785
302 bios 타이머 및 시간 설정 호스트웨이 2015.09.18 4826
301 iotop 사용하기 호스트웨이 2015.09.14 4914
300 Web site에서 php error log 출력하지 않기 호스트웨이 2012.11.01 5047
299 패키지에 포함된 리스트 확인하기 호스트웨이 2012.12.07 5084
298 리눅스 파일 및 디렉토리 권한 관리 file 호스트웨이 2015.09.13 5181
297 리눅스 캐시 메모리 비우기 file 호스트웨이 2012.12.26 5267
296 Linux -(하이픈)으로 시작하는 파일 지우기 호스트웨이 2015.09.20 5497
295 Proftp 설치 및 xinetd 에서 실행하기 file 호스트웨이 2015.09.18 5588
294 dumpe2fs - 파일시스템 상세 정보 확인 호스트웨이 2015.09.18 5611
293 서버 네트워크 대역폭 제한 호스트웨이 2015.09.20 5715
292 LAN 카드에 여러개의 IP 주소 할당 호스트웨이 2015.09.18 5768
291 tar 분할압축하기 호스트웨이 2015.09.19 5872
290 Linux chkrootkit을 이용한 백도어 설치 탐지 호스트웨이 2015.09.18 5932
289 lrzsz 사용해보기 호스트웨이 2012.10.12 6059
288 Touch 파일 용량 0바이트 만들기 호스트웨이 2015.09.20 6111
287 ls -l 출력 시 날짜형태 변경 호스트웨이 2012.12.27 6128