Reputation: 317
I need your help to understand logrotate behaviour .
logrotate.conf
:
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
In the logrotate.d
directory, I have for example one file called consul-log
:
/var/log/consul {
size 500M
missingok
rotate 0
compress
notifempty
copytruncate
}
In the /var/lib/logrotate.status
, file I can see these lines (related to the consul log file):
logrotate state -- version 2
"/var/log/consul" 2016-1-25
My question is:
rotate 4
inside logrotate.conf
, but I have rotate 0
inside logrotate.d/consul-log
, will logrotate use rotate 0
or rotate 4
?Upvotes: 1
Views: 1927
Reputation: 52152
For /var/log/consul
, it will use rotate 0
. Quote from the man page:
Each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones) and specify logfiles to rotate.
In your case, rotate 0
is both local and later.
Upvotes: 1
Reputation: 3471
With respect to your question:
If I have
rotate 4
insidelogrotate.conf
, but I haverotate 0
insidelogrotate.d/consul-log
, will logrotate userotate 0
orrotate 4
?
logrotate.conf
is the configuration file for the systemwide changes and any other configuration file which you create in the logrotate.d
folder will be overriden.
Because of this directive:
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
Upvotes: 1