Quantcast
Channel: User Nathan Basanese - Stack Overflow
Viewing all articles
Browse latest Browse all 64

Does logrotate remove .gz files? That is, does logrotate with a * path rotate an existing .gz file?

$
0
0

// , The question's a bit ambiguous.

Here is the scenario:

I have logs with the following three extensions, but my current rule only applies to *.log files:

.1
.log
.txt

Plus, because Tomcat is rotating logs, I have the following:

.gz

I want to rotate all of these files, but I don't want to end up with any .gz.gz files. How do I do this?

Logrotate Rule for Tomcat

Currently, I have the following rule for the Tomcat logs:

% sudo cat /etc/logrotate.d/tomcat
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET.  ANY CHANGES WILL BE
# OVERWRITTEN.

/opt/apache-tomcat_1/logs/*.log {
  compress
  daily
  delaycompress
  maxage 60
  maxsize 500M
  minsize 1k
  rotate 20
  size 100k
}

To try to solve this, I could change the /opt/apache-tomcat_1/logs/*.log path to something like /opt/apache-tomcat_1/logs/*, but I wonder if that would re-compress or process the .gz files in the same way as the .log and .txt files.

Does logrotate have some way of knowing to leave existing .gz files well enough alone?

Other Files

The last time the /etc/cron.daily/logrotate got an update was about 12 days ago:

% sudo ls -lanh /etc/cron.daily/logrotate
-r-xr-xr-x 1 0 0 313 Jun 29 21:48 /etc/cron.daily/logrotate

Its contents are as follows:

#!/bin/sh
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET.  ANY CHANGES WILL BE
# OVERWRITTEN.

OUTPUT=$(/usr/sbin/logrotate /etc/logrotate.conf 2>&1)
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
    echo "${OUTPUT}"
fi
exit $EXITVALUE

And, in case it's relevant:

% cat /etc/logrotate.conf
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET.
# ANY CHANGES WILL BE OVERWRITTEN.

create
weekly
rotate 4

# configurable file rotations
include /etc/logrotate.d

I did a quick search online for this, and found some results. The askubuntu.com answer was closest, but I am still not sure whether logrotate will "rotate" .gz files created by another service, like Tomcat.

Nothing in those results answers this specific question about pre-existing .gz files created by another service (e.g. Tomcat) when * globbing is used in the logrotate path.

Right now I'm simply solving this with multiple paths/rules: https://v.gd/yNfAAu

But I'm curious. What script behavior intelligently makes logrotate ignore the existing .gz files, or process them differently, while still removing those that are sufficiently old or large? Does Logrotate have a way to do this already?


Viewing all articles
Browse latest Browse all 64

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>