logrotate로 회전하려는 ‘apache’사용자의 로그 파일 소유자가 있습니다.
다른 사용자로 logrotate를 실행하여 copytruncate 전략을 사용하여 ‘web’이라고 말하고 싶습니다.
이 오류로 실패합니다.
error: error setting owner of ./logfile.log.1: Operation not permitted
그러나 logrotate가 새 파일의 소유자를 회전 된 파일의 소유자, 즉 아파치로 변경하려고 시도하기 때문입니다. 그러나 logrotate가 소유자로 ‘web’을 사용하여 사본을 만들면 정상적으로 작동 할 수 있다면 동일한 소유자가있는 새 파일에 대해서는 신경 쓰지 않습니다.
그래서 logrotate가 복사 된 파일의 소유자를 변경하지 못하게하는 방법이 있습니까?
답변
파일 에서 create
지시문을 사용 /etc/logrotate.d/
합니다. 예:
create 0664 www-data www-data
답변
create
질문의 마지막 문장에 설명 된 내용을 수행 할 수 있지만이 옵션은와 호환되지 않으며 copytruncate
사용하고 싶다고 말합니다.
답변
postrotate 및 prerotate 옵션과 동일한 문제를 해결했습니다.
/opt/bars/web_edu/var/log/nginx*.log {
su web_edu web_edu
daily
compress
missingok
rotate 30
dateext
notifempty
create 0644 web_edu web_edu
sharedscripts
prerotate
chown web_edu:web_edu /opt/bars/web_edu/var/log/nginx*.log
endscript
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` || true
chown web_edu:web_edu /opt/bars/web_edu/var/log/nginx*.gz
chown web_edu:web_edu /opt/bars/web_edu/var/log/nginx*.log
endscript
}