title: Logrotate to clean up date stamped files
body: <p>I'm currently trying to work out a method of tidying up Oracle Recover log files that are created by Cron... </p>
  
  <p>Currently, our Oracle standby recover process is invoked by Cron every 15mins using the following command:</p>
  
  <pre><code>0,15,30,45 * * * * /data/tier2/scripts/recover_standby.sh SID &gt;&gt; /data/tier2/scripts/logs/recover_standby_SID_`date +\%d\%m\%y`.log 2&gt;&amp;1
  </code></pre>
  
  <p>This creates files that look like:</p>
  
  <pre><code>$ ls -l /data/tier2/scripts/logs/
  total 0
  -rw-r--r-- 1 oracle oinstall 0 Feb  1 23:45 recover_standby_SID_010213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  2 23:45 recover_standby_SID_020213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  3 23:45 recover_standby_SID_030213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  4 23:45 recover_standby_SID_040213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  5 23:45 recover_standby_SID_050213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  6 23:45 recover_standby_SID_060213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  7 23:45 recover_standby_SID_070213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  8 23:45 recover_standby_SID_080213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb  9 23:45 recover_standby_SID_090213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb 10 23:45 recover_standby_SID_100213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb 11 23:45 recover_standby_SID_110213.log
  -rw-r--r-- 1 oracle oinstall 0 Feb 12 23:45 recover_standby_SID_120213.log
  </code></pre>
  
  <p>I basically want to delete off files older than x days old, which I thought logrotate would be perfect for... </p>
  
  <p>I've configured logrotate with the following config file:</p>
  
  <pre><code>/data/tier2/scripts/logs/recover_standby_*.log {
      daily
      dateext
      dateformat %d%m%Y
      maxage 7
      missingok
  }
  </code></pre>
  
  <p>Is there something I'm missing to get the desired outcome? </p>
  
  <p>I guess I could remove the date from the Crontab log file, and then have logrotate rotate that file, however then the date in the log file wont reflect the day the logs were generated... i.e. Recoveries on 010313 would be in file with a date of 020313 due to logrotate firing on 020313 and rotating the file... </p>
  
  <p>Any other ideas?
  And thank-you in advance for any responses. </p>
  
  <p>Regards</p>
  
  <p>Gavin </p>