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

번호 제목 글쓴이 날짜 조회 수
106 CentOS 6 – root 패스워드 변경하기 호스트웨이 2012.04.20 22370
105 부하 테스트 - 1편 / 시스템 하드웨어 stress tool 호스트웨이 2012.04.20 30879
104 파일 내용 출력 관련된 명령어 호스트웨이 2012.04.20 18276
103 리눅스 커널 버전 의미 file 호스트웨이 2012.04.20 27112
102 Telnet을 이용하여 Linux서버 원격접속 file 호스트웨이 2012.04.13 20536
101 리눅스에서 iso 이미지 활용하기 호스트웨이 2012.04.13 19400
100 ngrep 사용법 호스트웨이 2012.04.13 16812
99 국가명 약어 (국가코드) 호스트웨이 2012.04.13 65008
98 서비스 이름으로 포트 번호 확인하기 호스트웨이 2012.04.13 57736
97 chattr 명령을 이용한 파일 속성 변경 file 호스트웨이 2012.04.07 18564
96 vsftpd.conf 옵션 설명 호스트웨이 2012.04.06 16819
95 서버 아이피 변경으로 인한 다량의 네임서버 존파일 일괄 변경 방법 호스트웨이 2012.04.06 14685
94 ipv6 비활성화 하기 호스트웨이 2012.04.06 25465
93 계정 생성 시 ftp 계정만 주고 Shell 로그인 차단하기 file 호스트웨이 2012.04.06 23717
92 Linux lastlog를 이용한 최근 접속정보 확인 file 호스트웨이 2012.04.06 19747
91 VI 편집기에서 사용되는 명령어(2) 호스트웨이 2012.04.06 13737
90 Linux Charset 확인 및 변경 file 호스트웨이 2012.03.30 85160
89 VI 편집기에서 사용되는 명령어 호스트웨이 2012.03.30 13909
88 Linux 서버 root password 분실시 변경 방법 file 호스트웨이 2012.03.30 24006
87 find 명령어-1 호스트웨이 2012.03.30 14935