09_logrotate 설정

logrotate 설정

1. 환경

  • logstate 가 이미 설치되어 있기 때문에 설정만 진행

2. 설정대상

  • /etc/logrotate.d/mongodb
  • /etc/logrotate.d/nginx

2-1. mongodb

# vi /etc/logrotate.d/mongodb
/mceadm/apps/mongo/log/mongod.log
{
    daily
    size 1000M
    missingok
    rotate 52
    compress
    delaycompress
    notifempty
    create 640 mongod mongod
    sharedscripts
    postrotate
        if  [ -f /var/run/mongodb/mongod.pid ]; then
            /bin/kill -SIGUSR1 `cat /var/run/mongodb/mongod.pid`
        fi
    endscript
}

Test

logrotate -v /etc/logrotate.d/mongodb

2-2 nginx

# vi /etc/logrotate.d/nginx
/mceadm/apps/nginx/log/*.log {
  daily
    missingok
    rotate 52
    compress
    delaycompress
    notifempty
    create 640 nginx adm
    sharedscripts
    postrotate
        if [ -f /var/run/nginx.pid ]; then
            kill -USR1 `cat /var/run/nginx.pid`
        fi
    endscript
}