定期清理es索引

2019-07-23  本文已影响0人  野草_疯长

清理索引脚本
vim clean-index.sh

#/bin/bash
DATA=`date -d "21 day ago" +%Y.%m.%d`       //指定日期(21天前)
time=`date`                                 //当前日期

curl -XGET "http://localhost:9200/_cat/indices/?v"|grep $DATA
if [ $? == 0 ];then                          //判断索引是否存在
curl -XDELETE "http://localhost:9200/*-${DATA}"  //删除n天前的日志
echo "于 $time 清理 $DATA 索引!"  >> /var/log/clean.log
fi

制定计划任务,定期执行脚本
crontab -e

00 00 * * *  sh clean-index.sh
上一篇下一篇

猜你喜欢

热点阅读