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

번호 제목 글쓴이 날짜 조회 수
366 TCp syn Flooding 공격시 대처방법 TIP 호스트웨이 2012.10.26 2238
365 vim fileformat 변경하기: -bash: ./LINUX_03.sh: /bin/sh^M: bad interpreter: No such file or directory 호스트웨이 2012.11.29 2292
364 리눅스 시스템상에서 하드웨어사양 확인 호스트웨이 2012.10.24 2369
363 500 FTP server shut down 문제 해결 호스트웨이 2015.09.09 2401
362 rsync / 파티션 전체 동기화 방법 호스트웨이 2012.12.14 2429
361 ispell 명령어를 통한 철자 검사 및 수정하기 file 호스트웨이 2012.10.12 2523
360 리눅스 look 명령어 file 호스트웨이 2012.11.02 2598
359 hostname 변경하기 호스트웨이 2015.09.17 2621
358 리눅스 hdd 속도 알아보기 호스트웨이 2015.09.17 2623
357 쉘 프롬프트 설정하기 file 호스트웨이 2012.11.08 2671
356 읽기 전용 파티션 읽고 쓸수 있게 재마운트하는 방법 호스트웨이 2015.09.13 2718
355 랜카드 본딩(bond0) 설정 호스트웨이 2012.11.16 2719
354 쉘 프롬프트에서 바로 이전 디렉토리로 이동하기 호스트웨이 2012.12.20 2751
353 UTF-8 환경에서 리눅스 한글 꺠짐 현상 해결법 호스트웨이 2015.09.08 2771
352 df 쉽게 보기 호스트웨이 2012.12.20 2835
351 /proc/sys/net/ipv4 활용 서버보안 -1- 호스트웨이 2015.09.17 2838
350 SNMPD LOG 안남게 하기 호스트웨이 2015.09.10 2891
349 리눅스 tree 명령어 file 호스트웨이 2012.09.21 2930
348 yum을 이용한 X-Window 설치 호스트웨이 2012.09.27 3005
347 INIT: no more processes left in this runlevel 메세지 발생시 호스트웨이 2012.11.15 3018