title: Does logrotate remove .gz files? That is, does logrotate with a * path rotate an existing .gz file?
body: <p>// , The question's a bit ambiguous.</p>
  <p>Here is the scenario:</p>
  <p>I have logs with the following three extensions, but my current rule only applies to *.log files:</p>
  <pre><code>.1
  .log
  .txt
  </code></pre>
  <p>Plus, because Tomcat is rotating logs, I have the following:</p>
  <pre><code>.gz
  </code></pre>
  <p><em><strong>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?</strong></em></p>
  <h1>Logrotate Rule for Tomcat</h1>
  <p>Currently, I have the following rule for the Tomcat logs:</p>
  <pre><code>% 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
  }
  </code></pre>
  <p>To try to solve this, I could change the <code>/opt/apache-tomcat_1/logs/*.log</code> path to something like <code>/opt/apache-tomcat_1/logs/*</code>, but I wonder if that would re-compress or process the <code>.gz</code> files in the same way as the <code>.log</code> and <code>.txt</code> files.</p>
  <p>Does <code>logrotate</code> have some way of knowing to leave existing <code>.gz</code> files well enough alone?</p>
  <h1>Other Files</h1>
  <p>The last time the <code>/etc/cron.daily/logrotate</code> got an update was about 12 days ago:</p>
  <pre><code>% sudo ls -lanh /etc/cron.daily/logrotate
  -r-xr-xr-x 1 0 0 313 Jun 29 21:48 /etc/cron.daily/logrotate
  </code></pre>
  <p>Its contents are as follows:</p>
  <pre><code>#!/bin/sh
  # THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET.  ANY CHANGES WILL BE
  # OVERWRITTEN.
  
  OUTPUT=$(/usr/sbin/logrotate /etc/logrotate.conf 2&gt;&amp;1)
  EXITVALUE=$?
  if [ $EXITVALUE != 0 ]; then
      /usr/bin/logger -t logrotate &quot;ALERT exited abnormally with [$EXITVALUE]&quot;
      echo &quot;${OUTPUT}&quot;
  fi
  exit $EXITVALUE
  </code></pre>
  <p>And, in case it's relevant:</p>
  <pre><code>% 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
  </code></pre>
  <p>I did a <a href="https://duckduckgo.com/?q=does%20logrotate%20rotate%20an%20existing%20.gz%20file" rel="nofollow noreferrer">quick search online</a> for this, and <a href="https://askubuntu.com/questions/593910/what-exactly-does-logrotate-do-to-apache-log-files-apache-2-4-ubuntu-14-04">found</a> <a href="https://linuxconfig.org/setting-up-logrotate-on-redhat-linux" rel="nofollow noreferrer">some</a> <a href="https://serverfault.com/questions/377031/logrotate-does-not-remove-old-logs">results</a>. The askubuntu.com answer was closest, but I am still not sure whether <code>logrotate</code> will &quot;rotate&quot; <code>.gz</code> files created by another service, like Tomcat.</p>
  <p>Nothing in those results answers this specific question about pre-existing .gz files created by another service (e.g. Tomcat) when <code>*</code> globbing is used in the logrotate path.</p>
  <p>Right now I'm simply solving this with multiple paths/rules: <a href="https://v.gd/yNfAAu" rel="nofollow noreferrer">https://v.gd/yNfAAu</a></p>
  <p>But I'm curious. What script behavior intelligently makes <code>logrotate</code> ignore the existing <code>.gz</code> files, or process them differently, while still removing those that are sufficiently old or large? Does Logrotate have a way to do this already?</p>