>_ IzzyLab

Topic breakdown

The task ties together finding files by age and packing them: find can select files by modification time with the -mtime predicate, where a value with a plus means "older than N days". The selected list is conveniently fed to tar, which can read the names of the files to pack from a separate list (including from stdin via a pipe) and compress the archive with gzip right away. The originals are cleanest to delete with the same find and the same age filter after the archive is created — that way fresh files are guaranteed not to be harmed.

What's checked

  1. old logs collected into old-logs.tar.gz
  2. originals of old logs deleted
  3. fresh logs stayed and didn't get into the archive

What it looks like