2008.05.19 20:33
roglotate 라는 패키지를 이용하여 로그를 관리하는 방법에 대하여 알아봅니다.
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)을 실행합니다.
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
26 | tcpdump 기본 사용 | sylee | 2008.07.02 | 39641 |
25 | 특정 계정만 su 명령어 사용 | 호스트웨이 | 2012.05.05 | 39719 |
24 | VSFTP 에서 사용하는 port를 변경하기 | 호스트웨이 | 2012.03.23 | 39723 |
23 | openssl 간단 사용법 | 호스트웨이 | 2008.12.10 | 41116 |
22 | 리눅스 Sleep 명령어 | 호스트웨이 | 2012.08.10 | 42166 |
21 | 터미널 창으로 메시지 보내기 | 호스트웨이 | 2008.05.19 | 44239 |
20 | ssh-key를 생성하여 서버에 패스워드 없이 접속하는 방법 | jook | 2008.06.25 | 44757 |
19 | Kernel Parameters | HOSTWAY | 2008.06.04 | 45459 |
18 | /bin/false, /sbin/nologin 의 차이점 | 호스트웨이 | 2012.08.10 | 45876 |
17 | 시스템 시간 확인 및 동기화 하기 | sylee | 2008.05.15 | 46982 |
16 | history 조회시 '날짜,시간' 표시하기 | 호스트웨이 | 2012.03.16 | 49594 |
15 | xinetd 소개 및 설정 | 호스트웨이 | 2012.06.29 | 51913 |
14 | top 명령어 및 옵션 설명 | 호스트웨이 | 2012.03.27 | 52564 |
13 | 강제 umount 방법 (umount : device is busy 발생시) | 호스트웨이 | 2012.11.30 | 55499 |
12 | 서비스 이름으로 포트 번호 확인하기 | 호스트웨이 | 2012.04.13 | 57736 |
11 | fdisk 명령어를 이용하여 수동으로 파티션 나누기 | 호스트웨이 | 2015.11.30 | 57740 |
10 | 비대해진 로그 파일 내용을 비우는 방법 - /dev/null | 호스트웨이 | 2012.03.16 | 61423 |
9 | head 와 tail 사용하기 | sylee | 2008.05.14 | 63485 |
8 | 국가명 약어 (국가코드) | 호스트웨이 | 2012.04.13 | 65007 |
7 | Swap 메모리 늘리기 | 호스트웨이 | 2012.03.30 | 67218 |