0

I have found this regarding deletion of old files in bash: Delete all but the most recent X files in bash

I want the same functionality, however I cannot apply the same principles in my script as it is interacting with an amazon s3 directory.

Does anyone know how to use amazon CLI to achieve this?

Community
  • 1
  • 1

1 Answers1

1

Well you can just create a lifecycle rule on S3 to delete older files. Then this process is done automatically for you.

Otherwise I guess you need to LIST all objects' metadata and write a script that checks if the script is old enough. But if you have a lot of objects this can be quite costly, while the lifecycle rule is free.

Luc Hendriks
  • 2,473
  • 13
  • 18