Linux ETC

로그 관리

2008.05.19 20:33

호스트웨이 조회 수:25311

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

번호 제목 글쓴이 날짜 조회 수
286 비프음 콘트롤 호스트웨이 2009.02.12 25341
285 특정 사용자 계정 동시 로그인 수 제한 file 호스트웨이 2012.05.11 25312
» 로그 관리 호스트웨이 2008.05.19 25311
283 DHCP 환경에서의 resolv.conf 초기화 현상 호스트웨이 2012.03.09 25267
282 리눅스 touch 명령어 file 호스트웨이 2012.08.03 25230
281 php-5.2.x 설치 옵션 호스트웨이 2009.02.05 25098
280 CGI 환경 테스트 sylee 2008.05.21 25037
279 awk 를 이용한 패턴 처리 호스트웨이 2008.05.19 24933
278 debian .vimrc 활용 HOSTWAY 2009.04.15 24890
277 hdparm 옵션 알아보기 sylee 2010.02.04 24769
276 Linux 서버 root password 분실시 변경 방법 file 호스트웨이 2012.03.30 24645
275 리눅스 APM 소스설치시 Error 및 해결 방법 호스트웨이 2012.09.21 24629
274 Rsync를 이용한 데이터 Sync, 백업하기 – 2탄 호스트웨이 2012.07.13 24581
273 History 삭제하는 방법 및 현재한 history 삭제하는 방법 호스트웨이 2012.08.24 24575
272 리눅스 커널 업데이트 및 커널 변경 부팅 방법 file 호스트웨이 2014.10.30 24491
271 계정 생성 시 ftp 계정만 주고 Shell 로그인 차단하기 file 호스트웨이 2012.04.06 24390
270 samba 설정후, 한글 파일이 깨질때.. jook 2009.10.08 24267
269 grub-install 사용방법 호스트웨이 2012.05.04 24195
268 리눅스 ss 명령어 호스트웨이 2012.07.20 24137
267 리눅스에서 mii-tool 사용 방법 호스트웨이 2012.03.08 24067