Skip to content

Instantly share code, notes, and snippets.

@rblaine95
Last active March 2, 2023 16:13
Show Gist options
  • Save rblaine95/0efac36942b65ead99c9faa29d90ec6f to your computer and use it in GitHub Desktop.
Save rblaine95/0efac36942b65ead99c9faa29d90ec6f to your computer and use it in GitHub Desktop.
Delete objects in S3 older than 150d in parallel
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