Suffix logrotate: dateext + rotate

Can I use the date and rotation option at the same time?

config should look like this:

/var/log/verybig.log { monthly size=100M dateext dateformat .%Y%m rotate 5 create missingok compress } 

and I should get:

 /var/log/verybig.log /var/log/verybig.log-201408.1.gz /var/log/verybig.log-201408.2.gz /var/log/verybig.log-201408.3.gz /var/log/verybig.log-201408.4.gz /var/log/verybig.log-201408.5.gz /var/log/verybig.log-201409.1.gz /var/log/verybig.log-201409.2.gz /var/log/verybig.log-201409.3.gz /var/log/verybig.log-201409.4.gz /var/log/verybig.log-201409.5.gz 

But now with this configuration, logrotate debug tell me:

 destination /var/log/verybig.201409.gz already exists, skipping rotation 

It seems that logrotate cannot get a few suffix parameters, but maybe I'm just a bad reader person.

Using the date format in a date is a workaround, and I will not get the format I want.

+6
source share
2 answers

You can use the "date" as a suffix for the rotated file:

 dateext dateformat -%Y-%m-%d-%s 
+6
source

You can use the "date" as a suffix for the rotated file:

 /tem/messages { rotate 5 daily compress dateext dateformat -%Y-%m-%d.log } 

result: messages-2015-04-08.log.gz

0
source

Source: https://habr.com/ru/post/975288/


All Articles