Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logrotate suffix: dateext + rotate

Is it possible to use dateext and rotate options at the same time?

config must look like this:

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

and i must 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 config, logrotate's debug tell me:

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

Look like logrotate can't get multiple suffix-options, but maybe I just bad man-reader.

Using day in date format is workaround and I will not get format I want.

like image 848
strizhechenko Avatar asked Sep 15 '14 10:09

strizhechenko


People also ask

What is Dateext in logrotate?

logrotate with option dateext adds timestamp of tommorrow to a file rotated today.

How do you rotate logs with logrotate?

Handling Active Log File. In the default behavior, the rotation process beings by logrotate renaming the active log file into a different name. Then, it creates a new log file with the same name. Finally, it invokes other logic such as compress and mail to complete the rotation process.

What does rotate mean in logrotate?

rotate #: Keep specified number of files before deleting older log files. compress: Compress (gzip) log files. delaycompress: Delays compression until second time around. compresscmd: Set which command to used to compress.

How do I rotate var log syslog?

If you want to rotate /var/log/syslog it needs to be listed in a logrotate config file somewhere, and you just run logrotate . If it rotated recently, then logrotate -f to force it to do it again. So, you need that in a file, normally either /etc/logrotate. conf or as a file snippet in /etc/logrotate.


2 Answers

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

dateext dateformat -%Y-%m-%d-%s
like image 190
sfab Avatar answered Sep 19 '22 15:09

sfab


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

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

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

like image 38
Leo Avatar answered Sep 19 '22 15:09

Leo