I need a utility that could clean up old files (logs, stats, temporary files, caches, etc) in a given directory, possibly recursively, based on a combination of at least some of the following criteria:
- Keep certain specified maximum number of files and delete the older ones
- Keep the latest files based on maximum retained total size
- (variation of #2) Keep the latest files with total size up to % of total/remaining space on that device
- Remove files older than certain age
An existing GNU find
command provides solution for #4, but that is just one thing it can do.
Writing a utility like that wouldn’t take long, but if there was an existing solution I’d rather use that rather than reinventing the wheel.