![Logrotate 名称中带有时间戳的文件](https://linux22.com/image/34899/Logrotate%20%E5%90%8D%E7%A7%B0%E4%B8%AD%E5%B8%A6%E6%9C%89%E6%97%B6%E9%97%B4%E6%88%B3%E7%9A%84%E6%96%87%E4%BB%B6.png)
看起来应该有效:
"/usr/local/tomcat/logs/" {
daily
compress
delaycompress
copytruncate
rotate 1
prerotate
/usr/bin/find /usr/local/tomcat/logs/ -name stupidLogWithTimestamp* -size -10k -delete
/usr/bin/find /usr/local/tomcat/logs/ -name stupidLogWithTimestamp* -mtime +3 -delete
endscript
}
我想对 3 天以内的日志进行 1 次轮换,并删除所有大小小于 10k 的内容。每当我尝试手动运行它时,我都会得到:
rotating pattern: "/usr/local/tomcat/logs/" forced from command line (no old logs will be kept)
empty log files are rotated, old logs are removed
一切都没有改变。我一直在搜索堆栈溢出,但找不到与此相关的任何内容。
答案1
我想到了。我必须在第一行使用正则表达式:所以这样:
"/usr/local/tomcat/logs/"
应该是这样的:
"/usr/local/tomcat/logs/stupidLogWithTimestamp*"