關於使用logrotate對nginx的日誌分割時資料夾許可權問題解答
在使用logrotate對nginx的日誌進行分割的時候系統報錯,error資訊:
error: skipping "/var/log/nginx/access.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.
提示沒有許可權訪問nginx/access.log,看過其他人遇到的情況,處理辦法是在/etc/logrotate.d/nginx檔案中添su root list,新增後的nginx檔案:
/var/log/nginx/*.log {
su root list
daily
missingok
rotate 52
compress
delaycompress
notifempty
#ifempty
create 0640 www-data adm
sharedscripts
postrotate
[ ! -f/var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
}
但是實際並沒有解決我的問題,然後其實通過修改許可權的方式解決問題的,修改為:
drwx------+ 2 nginx nginx 4096 Mar 22 09:16 nginx
希望有幫助