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.
logrotate with option dateext adds timestamp of tommorrow to a file rotated today.
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.
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.
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.
You can use "date" as a suffix of the rotated file:
dateext dateformat -%Y-%m-%d-%s
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With