--- title: "Deleting Large Buckets via Lifecycle Policies" slug: "deleting-large-buckets-via-lifecycle-policies" updated: 2023-01-09T23:34:20Z published: 2023-01-09T23:34:20Z canonical: "docs.serversaustralia.com.au/deleting-large-buckets-via-lifecycle-policies" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.serversaustralia.com.au/llms.txt > Use this file to discover all available pages before exploring further. # Deleting Large Buckets via Lifecycle Policies When you have a bucket with 10s of millions of files, deleting via multi-object delete (max 1000 per delete request) will take longer than client application or load balancer timeouts. A way to deal with deleting these massive buckets without the potential for failures/timeouts is to set a bucket Lifecycle Policy. By doing this the Lifecycle processes run by the backend storage nodes will handle the deleting of objects in the background. This also allows the tenant to handle the deletion process without needing an operator/admin to be involved. Below are two examples of a policy that expires objects after 1 day, one in JSON for **awscli** and one in XML for **s3cmd**. Both assume the clients are already configured with the appropriate credentials. Once all the objects are deleted from the bucket, the bucket can be deleted as normal. ## awscli expire.json ```json { "Rules": [ { "ID": "delete-all-objects", "Prefix": "", "Status": "Enabled", "Expiration": { "Days": 1 } }, { "ID": "delete-prior-versions", "Prefix": "", "Status": "Enabled", "Expiration": { "Days": 1 }, "NoncurrentVersionExpiration": { "NoncurrentDays": 3 } }, { "ID": "delete-incomplete-multipart-uploads", "Prefix": "", "Status": "Enabled", "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 1 } } ] } ``` Then run the command: ```shell aws s3api put-bucket-lifecycle --bucket --lifecycle-configuration file://expire.json ``` ## s3cmd lifecycle_policy.xml ```markup delete-all-objects Enabled 1 delete-prior-versions Enabled 1 3 delete-incomplete-multipart-uploads Enabled 1 ``` Then run the command: ```shell s3cmd setlifecycle lifecycle_policy.xml s3:// ``` You will see output similar to this: ```shell s3://bucketname/: Lifecycle Policy updated ```