Home > Enterprise >  Delete log files from AWS Bucket using AWS CLI
Delete log files from AWS Bucket using AWS CLI

Time:06-13

I am trying to clean up one of my buckets on AWS and need a solution to delete only log files from the entire bucket and not delete any other files or folders. Is there a way by using AWS CLI to do this?

CodePudding user response:

You do not state how to distinguish log files in your buckets from other files. The CLI has some relevant support. You can use the "recursive" flag to delete multiple files. And the section on include and exclude patterns has several examples.

Note that this still lists many objects! In many cases, particularly for log files, you may be better off using S3 lifecycle rules. Some useful examples of lifecycle rules may be helpful to see if you want to use these.

  • Related