logrotate configuration file syntax - multiple wildcard entries possible?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: City Beneath the Waves Looping
--
Chapters
00:00 Logrotate Configuration File Syntax - Multiple Wildcard Entries Possible?
01:22 Accepted Answer Score 135
02:02 Answer 2 Score 50
02:21 Answer 3 Score 12
03:23 Thank you
--
Full question
https://superuser.com/questions/255951/l...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #debian #logging #debiansqueeze #logrotate
#avk47
ACCEPTED ANSWER
Score 135
Yes, you can use multiple wild cards. You can test your file without performing the actual rotations by doing this:
logrotate -d -f /etc/logrotate.conf
-d = Turns on debug mode. In debug mode, no changes will be made to the logs or to the logrotate state file.
-f = Tells logrotate to force the rotation, even if it doesn’t think this is necessary. Sometimes this is useful after adding new entries to logrotate, or if old log files have been removed by hand, as the new files will be created, and logging will con- tinue correctly.`
ANSWER 2
Score 50
I just wanted to clarify, because that's what I got here looking how to do,
Multiple log files are allowed to be specified for a single config, eg
/var/log/httpd/access.log
/var/log/httpd/error.log
/var/log/httpd/mysite/*.log
{
rotate 5
mail nobody@example.org
size 100k
sharedscripts
postrotate
/usr/bin/killall -HUP httpd
endscript
}
ANSWER 3
Score 12
From man page for logrotate:
Note that log file names may be enclosed in quotes (and that quotes are required if the name contains spaces). Normal shell quoting rules apply, with ', ", and \ characters supported.
Please remember to modify or remove quotation marks when going from single to multiple patterns:
This works:
/var/log/*.log /var/log/*.blog {
this works too:
/var/log/*.log
/var/log/*.blog {
This does not work:
'/var/log/*.log /var/log/*.blog' {
and neither this:
"/var/log/*.log /var/log/*.blog" {
Compare with the single pattern case.
This works:
'/var/log/*.log' {
and this works too:
"/var/log/*.log" {
Tested with logrotate 3.10.0
Edit: This works too:
"/opt/logs/*.log" "/opt/logs/dir with space/*.log" {
And multiline with quotes also works:
"/opt/logs/*.log"
"/opt/logs/dir with space/*.log" {
Tested with logrotate 3.14.0