Logrotate日誌切割報錯 檔案不再同一個使用者組下

偶-木發表於2017-12-08

分割日誌時報錯:

error: skipping "/var/log/nginx/test.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.

xx 檔案所屬使用者

新增“su root xx”到/etc/logrotate.d/nginx檔案中即可
如下;

/var/log/nginx/*.log {
        su root public
        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
}

相關文章