![logrotate 描述符可以处理多个通配符吗?](https://linux22.com/image/123228/logrotate%20%E6%8F%8F%E8%BF%B0%E7%AC%A6%E5%8F%AF%E4%BB%A5%E5%A4%84%E7%90%86%E5%A4%9A%E4%B8%AA%E9%80%9A%E9%85%8D%E7%AC%A6%E5%90%97%EF%BC%9F.png)
例如,在syslog
收集器上,远程syslog
进入,我的配置/var/syslog/<host>/*.log
中可以有类似以下内容:logrotate
/var/syslog/*/*.log {
daily
keep 7
compress
delaycompress
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
答案1
引用自rfaircloth.com:
创建日志轮换配置
/etc/logrotate.d/splunk-syslog
:
/var/splunk-syslog/*/*.log {
daily
compress
delaycompress
rotate 4
ifempty
maxage 7
nocreate
missingok
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd-ng.pid 2> /dev/null` 2> /dev/null || true
endscript
}
这是至少从 RHEL/CentOS 7 和 Ubuntu 16 LTS 开始的 OOTB 功能。