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)을 실행합니다.

번호 제목 글쓴이 날짜 조회 수
386 cdp 백업 프로세스 관련 호스트웨이 2015.09.07 1007
385 Linux vmstat 명령어 호스트웨이 2015.09.08 1094
384 현재 접속 사용자(머신/디바이스)수 알아내기 호스트웨이 2012.11.16 1130
383 잘못푼 압축파일(tar.gz) 지우는 방법 호스트웨이 2012.12.07 1273
382 sftp 서비스 막기 호스트웨이 2012.12.27 1320
381 우분투 서버에 JDK7 설치하기 호스트웨이 2015.09.13 1360
380 Linux 외장 저장장치 mount file 호스트웨이 2015.09.10 1397
379 2015년 7월1일 윤초 발생 관련 점검 방안 file 호스트웨이 2015.06.30 1558
378 리눅스 whereis 명령어 file 호스트웨이 2012.09.28 1634
377 Log file 주기적으로 정리하기 호스트웨이 2015.09.08 1644
376 특정 파일이 소속된 rpm 패키지 찾기 호스트웨이 2012.12.14 1782
375 arch 명령어를 통해 컴퓨터 종류 알기 file 호스트웨이 2012.11.16 1797
374 리눅스 free 명령어 호스트웨이 2012.12.26 1819
373 locate 명령어를 이용해 빠르게 지정한 파일 찾기 file 호스트웨이 2012.12.12 1859
372 queryperf 설치 및 사용 방법 (DNS 스트레스 테스트) 호스트웨이 2012.11.29 1871
371 kbd_mode 명령어를 통해 인식중인 키보드모드 출력 및 변경하기 file 호스트웨이 2012.11.06 1896
370 /proc 디렉터리내 파일 정보 알아보기 호스트웨이 2012.11.21 1917
369 top 사용 추가 tip 호스트웨이 2015.09.15 2016
368 limits.conf 설명 file 호스트웨이 2012.11.09 2133
367 free -m 에서 free (남는 메모리 양) 최소량 제한하기 호스트웨이 2012.12.21 2147