![LogRotate:运行非共享后旋转脚本时出错](https://linux22.com/image/156974/LogRotate%EF%BC%9A%E8%BF%90%E8%A1%8C%E9%9D%9E%E5%85%B1%E4%BA%AB%E5%90%8E%E6%97%8B%E8%BD%AC%E8%84%9A%E6%9C%AC%E6%97%B6%E5%87%BA%E9%94%99.png)
在每日日志轮转期间,我们收到以下错误。
/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
让我知道我哪里出错了。