I want to specify as follows in the logrotate configuration file.
/etc/logrotate.d/nanika_no_service
/var/log/nanika_no_service/【"aiueo"Other than logs starting with].log {
monthly
}
/var/log/nanika_no_service/aiueo.log {
daily
}
It seems impossible. Inevitably, compromise below.
/etc/logrotate.d/nanika_no_service
/var/log/nanika_no_service/[!a]*.log {
monthly
}
/var/log/nanika_no_service/a*.log {
daily
}
https://github.com/logrotate/logrotate/blob/master/logrotate.c https://github.com/logrotate/logrotate/blob/master/config.c
According to the source code, glob is used to search for files to rotate. So, I also read the specifications of glob, but there was no way to write "other than multiple characters", although there was a guide for wildcards "other than single characters".
That's why the logrotate.conf file specification
/var/log/nanika_no_service/【"aiueo"Other than logs starting with].log {
#Abbreviation
}
The conclusion so far is that it cannot be written as above. Is there a good way?
I want to rotate only one type of log under different conditions for logs in the same directory. That's why I investigated it. In the above example, ʻaiueo.log` corresponds to that.
but please wait a moment. Wouldn't it be better to write as follows without using [!]
?
/etc/logrotate.d/nanika_no_service
/var/log/nanika_no_service/*.log {
monthly
}
/var/log/nanika_no_service/aiueo.log {
daily
}
I agree. I expected that too. But unfortunately it is NG.
The logrotate setting does not work well with duplicates. If you do the above, ʻaiueo.logwill also be included in
* .log and there will be duplicate settings. Under these conditions, an error will occur at runtime, or ʻaiueo.log
will also follow the setting of * .log
(depending on the setting order, but forget which sequence will be what behavior). I did).
In this post, I investigated whether it is possible to express "other than multiple characters" in the target log specification of logrotate. Unfortunately, I haven't found a way to do it so far.
Good luck.
Recommended Posts