在每日日志轮转期间,我们收到以下错误。
/usr/bin/find: cannot delete ‘/var/log/tomcat/catalina.out’: Permission denied error: error running non-shared postrotate script for /var/log/tomcat/xdlogger.log of '/var/log/tomcat/*.log'
这是我的 logrotate 配置。
# cat /etc/logrotate.d/tomcat
/var/log/tomcat/*.txt
/var/log/tomcat/*.log
/var/log/tomcat/catalina.out {
copytruncate
daily
dateext
rotate 3
compress
missingok
postrotate
/usr/bin/find /var/log/tomcat/ -type f ! -name 'catalina.out' -mtime +5 -delete
endscript
}
catalina.out 和 xdlogger.log 的权限如下。
# stat /var/log/tomcat/catalina.out
File: `/var/log/tomcat/catalina.out'
Size: 16061 Blocks: 32 IO Block: 4096 regular file
Device: fd05h/64773d Inode: 41 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 70/ www) Gid: ( 0/ root)
Access: 2019-07-11 03:17:16.056809957 -0500
Modify: 2019-07-11 07:14:48.331588384 -0500
Change: 2019-07-11 07:14:48.331588384 -0500
# stat /var/log/tomcat/xdlogger.log
File: `/var/log/tomcat/xdlogger.log'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd05h/64773d Inode: 1433 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 70/ www) Gid: ( 70/ www)
Access: 2019-07-11 03:17:16.044810362 -0500
Modify: 2019-07-11 03:17:16.044810362 -0500
Change: 2019-07-11 03:17:16.044810362 -0500
让我知道我哪里出错了。