Created
April 24, 2019 14:42
-
-
Save math3vz/e375808acd881dd225f84a4c56bb9c6e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# : ${2?"Usage: $0 [number of days] [base url of elastic]"} | |
days="30" | |
baseURL=${2} | |
indexes=("my-cool-index" "my-not-so-cool-index") | |
for i in "${indexes[@]}" | |
do | |
: | |
curl -XPOST "$baseURL/$i/_delete_by_query" -H 'Content-Type: application/json' -d " | |
{ | |
\"query\": { | |
\"range\": { | |
\"datetime\": { | |
\"lt\": \"now-"$days"d/d\" | |
} | |
} | |
} | |
}" | |
printf "\n\n"; | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment