By using AWS re:Post, you agree to the Terms of Use

Can't empty (full!) bucket


Somehow one of my S3 buckets got full of THOUSANDS of log files. I'm not sure what they are or how they got there, but there are tons of files that are 692(ish) bytes. I'm trying to empty the bucket to delete it, but every time I do that it takes so long to delete all the files that I think it gets stuck when my display goes to sleep. It's currently stuck after deleting 2,017,996 files that amount to 1.5 gig. Similar thing happened after leaving it on overnight last night. Any ideas how to get rid of this bin so I stop being charged for it? Is there some backend way to delete a bin without emptying it, or a hack to empty literally millions of files??

2 Answers

There are a variety of options you can use to empty a bucket. They are listed here.

A really good option is to have lifecycle policies do the deletion (expiration) for you. See this link for setting up a lifecycle policy and this link specifically covers expiration. With this you can have the policy expire/delete any objects that are older than X. That should help you remove anything old. One thing to keep in mind is that there might be a delay between the expiration date and the date at which Amazon S3 removes an object. You are not charged for expiration or the storage time associated with an object that has expired.

profile picture
answered a month ago
  • I'll give this a try. I have a new rule set for current versions to expire after one day. That should do it, correct? Or do I need to do anything with noncurrent versions? (THANK YOU!!)

  • That should do it! If you have versioning turned on, you may also want to include the noncurrent versions. If you don't have it on, you should be covered. Keep in mind that once the object is deleted, it's gone forever!

Accepted Answer

Thank you, Paul! So far all my files are still there, so I just added a noncurrent rule to try that. I'll leave it over the weekend and hope to come back to an empty bucket next week. Thanks again.

answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions