log 관리 150 150 phobe

log 관리

아파치 로그가 작년 7월 23일 을 기준으로 갱신 되지 않는다.
뭐가 문제야. 로그 로테이트를 시뮬레이션 해보면

]# logrotate -d /etc/logrotate.d/httpd
error: skipping "/var/log/httpd/yeohang.co.kr-error_log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

/var/log/httpd/ 디렉토리의 권한이 너무 높게(777 또는 775 등) 설정되어 있어서, 보안상의 이유로 logrotate가 작업을 거부하고 있는 상황
디렉토리 권한 수정 (가장 권장)
logrotate 설정에 su 지시어 추가 – 난 아파치가 로그를 관리해야 하니까. 775 유지를 해야함

]# vi /etc/logrotate.d/httpd
# Note that logs are not compressed unless "compress" is configured,
# which can be done either here or globally in /etc/logrotate.conf.
/var/log/httpd/*log {
    su root apache <- 추가
    missingok
    ......
}

]# logrotate -d /etc/logrotate.d/httpd <- 시뮬레이션
]# logrotate -f /etc/logrotate.d/httpd <- 실행

또한 묵은 로그를 날려야지. 7일 이전 로그 삭제. 응용 가능

]# find /var/log/httpd/ -name "*log.*" -mtime +7 -delete
  • 포스트 태그: