1

The logs name are appended with timestamp when generated like log-20140526-062503.txt Is there a way to manage this? I tried with a custom state file but log rotate does not delete old file.

/var/logs/*.txt {
rotate 15
daily
compress
missingok
nocreate
}

Any help?

idris
  • 13
  • 1
  • 4

1 Answers1

2

The problem is that logrotate will consider every new logfile with this custom name to be a separate entity to rotate (just like access_log and error_log would be handled separately if the file pattern would be /var/log/httpd/*log). Thus, you will never get to 15 items to rotate.

One way around this might be with the maxage option:

maxage count

Remove rotated logs older than days. The age is only checked if the logfile is to be rotated. The files are mailed to the configured address if maillast and mail are configured.

but I am not sure if this really works.

If this doesn't work I would simply recommend to use a cron job that delete files older than 15 days matching your wildcard, as it appears that your app already uses a new log file every day.

Sven
  • 97,248
  • 13
  • 177
  • 225