Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is there an easy way to set up a bucket in s3 to automatically delete files older than x days?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

Amazon now has the ability to set bucket policies to automatically expire content:


share|improve this answer

Amazon has meanwhile introduced S3 lifecycles (see the introductory blog post Amazon S3 - Object Expiration), where you can specify a maximum age in days for objects in a bucket - see Object Expiration for details on its usage via the S3 API or the AWS Management Console.

share|improve this answer
+1 for providing an update regarding this outdated information, thanks! –  Steffen Opel Feb 26 '12 at 16:44

No, S3 is just a datastore. You'll need to use some outside client to periodically delete the old files.

share|improve this answer
This is no longer true: docs.amazonwebservices.com/AmazonS3/latest/UG/… –  Tarrant Oct 9 '12 at 23:44
Ah, that makes things much easier. Although, for my backups I still prefer to perform the deletion from my script, to make sure older backups are only purged when a new one has been made successfully. –  Martijn Heemels Oct 15 '12 at 8:34

You can use s3cmd to write a script to run through your bucket and delete files based on a precondition.

You'll need to write some code (bash, python) on top of it.

You can download s3cmd from http://s3tools.org/s3cmd

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.