We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
./deleate_index.sh $1 $2
./deleate_index.sh 3 logstash
#!/bin/bash set -eu DAYSAGO=`date --date="$1 days ago" +%Y%m%d` ALLLINES=`/usr/bin/curl -s -XGET http://127.0.0.1:9200/_cat/indices?v | egrep $2` echo echo "THIS IS WHAT SHOULD BE DELETED FOR ELK:" echo echo "$ALLLINES" | while read LINE do FORMATEDLINE=`echo $LINE | awk '{ print $3 }' | awk -F'-' '{ print $2 }' | sed 's/\.//g' ` if [ "$FORMATEDLINE" -lt "$DAYSAGO" ] then TODELETE=`echo $LINE | awk '{ print $3 }'` echo "http://127.0.0.1:9200/$TODELETE" fi done echo echo -n "if this make sence, Y to continue N to exit [Y/N]:" read INPUT if [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ] || [ "$INPUT" == "yes" ] || [ "$INPUT" == "YES" ] then echo "$ALLLINES" | while read LINE do FORMATEDLINE=`echo $LINE | awk '{ print $3 }' | awk -F'-' '{ print $2 }' | sed 's/\.//g' ` if [ "$FORMATEDLINE" -lt "$DAYSAGO" ] then TODELETE=`echo $LINE | awk '{ print $3 }'` /usr/bin/curl -XDELETE http://127.0.0.1:9200/$TODELETE sleep 1 fi done else echo SCRIPT CLOSED BY USER, BYE ... echo exit fi
The text was updated successfully, but these errors were encountered:
No branches or pull requests
./deleate_index.sh $1 $2
$1:时间,几天前。$2:索引名./deleate_index.sh 3 logstash
删除三天前索引名为logstash的所有数据The text was updated successfully, but these errors were encountered: