I have a file under logrotate.d that I would like not to run when the main logrotate is running.
I have created a separate job for this in /etc/crontab
45 23 * * * root mv /var/log/RemoteSystems/*/*.log /var/log/Archiv/ && logrotate /etc/logrotate.d/test
The job will move the files from a directory to another and then will apply logrotate. I would like that this job to run separately from main logrotate job in /etc/crontab
. The problem is that because "test" is under /etc/logrotate.d/
, it will run once again with the main logrotate.
Is there any command that I can insert in logrotate.conf that can exclude "test" to run?
I know that if I am having "test" file out of /etc/logrotate.d
, this will not happen, but I would like to keep "test" at the same path.
If you look at the manual
man logrotate.conf
, you can read findtabooext
option which enables you to exclude some files with specific extensions.You can choose one of the default excluded extensions like
.disabled
or you can specifiy your own additional extension like:All you need to do is to rename your file
/etc/logrotate.d/test
to have any of these extensions like/etc/logrotate.d/test.disabled
.You could edit the config file as below:
before
after
This should make only files ending
.conf
in/etc/logrotate.d/
to be picked up by logrotate excluding yourtest
fileIf you already have files in
/etc/logrotate.d/
being used by logrotate, these would need updated to include.conf
By placing the file
test
in the/etc/logrotate.d/
directory, it is going to be picked up by logrotate automatically.If you're wanting to run it manually, you can force it to carry out logrotate on the particular file no matter the location.
Where
/tmp/test
is the new location of the file.If you don't want to touch "test", you could try to modify the
include /etc/logrotate.d
directive in/etc/logrotate.conf
. By default it refers to a directory and thus parses all files in that directory, except for some file extensions.What you can try is, modify the include directory to refer to individual files under /etc/logrotate.d, example /etc/logrotate.d/apt etc. You exclude "test" from that list. I haven't tested this, but it might be worth trying.