Last active
March 2, 2023 16:13
-
-
Save rblaine95/0efac36942b65ead99c9faa29d90ec6f to your computer and use it in GitHub Desktop.
Delete objects in S3 older than 150d in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUCKET="this-is-not-proprietary" | |
JOBS=8 | |
aws s3api list-objects --bucket "$BUCKET" --query \ | |
"Contents[?LastModified<=\`$(date -v-150d '+%Y-%m-%d')\`][].{object: Key}" \ | |
| jq -r '.[].object' \ | |
| parallel -j$JOBS --colsep {} aws s3 rm s3://$BUCKET/{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment