自动删除 Elasticsearch 索引

#!/bin/bash
# author: Wang XiaoQiang
# crontab -e
# 0 0 * * * /root/script/del_esindex.sh
# auto delete day ago elasticsearch index dtime=`date -d "7 day ago" +%Y-%m-%d`
dtime_stamp=`date -d "$dtime" +%s` indexs=`curl -s 'http://127.0.0.1:9200/_cat/indices' | awk '$3~/^logstash/{print $3}'` for line in $indexs;do
index=$line
itime=`echo $line | awk -F - '{print $3}' | tr '.' '-'`
itime_stamp=`date -d "$itime" +%s` if [ $itime_stamp -lt $dtime_stamp ];then
curl -X DELETE "http://127.0.0.1:9200/$index" > /dev/null >&
fi
done
上一篇:sql server I/O硬盘交互


下一篇:jsp内置对象之request对象