2

I've a cron will generate daily file with format like data.log.YYYYMMDD and I want to use logrotate only to delete those file older than 5 days.

I tried this but not work. Any idea? Thanks.

/log/data.log.* { daily missingok rotate 0 maxage 5 }

sparkmix
  • 2,157
  • 3
  • 25
  • 33
  • Possible duplicate of [Logrotate to clean up date stamped files](https://stackoverflow.com/questions/14858752/logrotate-to-clean-up-date-stamped-files) – Ben Aveling Nov 12 '17 at 23:21

1 Answers1

3

It's not (easily) feasible... take a look at these posts:

The most easy way to do that is just to make a cron task: see this example, basically something like:

$ /usr/bin/find /data/tier2/scripts/logs/ -mtime +7 -name "*.log" -print -exec /bin/rm {} \;

Community
  • 1
  • 1
circulosmeos
  • 424
  • 1
  • 6
  • 19