Unix

user level logrotate 유저 레벨 logrotate

ForceCore 2016. 5. 25. 00:08

간단한 방법이 있었는데 까먹었다 으으 ㅋ

man logrotate 를 보면 설명이 나와있으니 참고하면 되는 듯.


우선 logrotate가 어떤 파일을 어떻게 관리하는지 설정 파일을 만들어야 한다.


~/.config/logrotate/logrotate.conf  (파일 이름과 위치는 자유)


# see "man logrotate" for details
# rotate log files daily
daily

# keep 4 weeks worth of backlogs
rotate 15

# restrict maximum size of log files
#size 20M

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# Logs are moved into directory for rotation
# olddir /var/log/archive

# Ignore pacman saved files
tabooext + .pacorig .pacnew .pacsave

/home/forcecore/.sopel/logs/exceptions.log {
    daily
    create 0664 forcecore forcecore
    minsize 1M
    rotate 15
}

/home/forcecore/.sopel/logs/raw.log {
    daily
    create 0664 forcecore forcecore
    minsize 1M
    rotate 15
}

/home/forcecore/.sopel/logs/stdio.log {
    daily
    create 0664 forcecore forcecore
    minsize 1M
    rotate 15
}


필자의 IRC 데몬 로그 관리용으로 만들었다. 저런 식이다...; 설명은 역시 man logrotate를 하면 자세히 나와 있다 다행히도.


저걸 설정으로 해서 실제로 돌게 하기 위해선 cron에 등록을 해야 한다... 크론을 설치해야 하네 -_-; Arch Linux에서 AUR도 아닌 기본 패키지로 제공되는 cronie로 설치했다.


크론을 설치했으니 이제 크론탭에 등록을 한다. 구체적인 명령어는 man logrotate 했을 때 나오는 명령어를 참고하면 됨.


@daily  /usr/bin/logrotate -s /home/forcecore/.config/logrotate/status /home/forcecore/.config/logrotate/logrotate.conf


참고해서 만든 명령어는 위와 같다.