问题原文
原帖链接 · MRA · CC BY-SA 3.0
For my logfiles I have the problem of all but one (or a few) files use the same configuration, while the rest has another one. I tried to realize this by giving a general configuration for all files and then overwriting this configuration for the few specific files later, e.g.:
/var/log/mylogs/*.log {
size 1000k
copytruncate
create 0644 root root
rotate 99
compress
missingok
}
/var/log/mylogs/thatonespecial.log {
size 1000k
copytruncate
create 0644 myuser mygroup
rotate 99
compress
missingok
}
However, this raises an error:
error: /var/log/mylogs/logrotate.conf:10 duplicate log entry for /var/log/mylogs/thatonespecial.log
How should I handle such a situation properly? I certainly don't want to list the large number of standard log files individually, so the use of the wildcard configuration seems reasonable to me. But how can I then specify an exception among the wildcarded files?
已采纳解答
原帖链接 · Hyppy · CC BY-SA 3.0
The most elegant answer is to put thatonespecial.log in a separate directory so it wouldn't be able to match the wildcard.
If that won't work, then you can use globs to narrow down your wildcard. It's messy, but if you absolutely can't move the file location then it's probably your only real option. Something like this:
/var/log/mylogs/[!t][!h]*.log
Would match any .log files with at least 2 characters in their name that don't start with "th".
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
