elasticsearch的索引清理

 

curl -XDELETE 'http://127.0.0.1:9200/winlogbeat-6.0.0-2017.07.*'

 

脚本加api删除(推荐)

cat es-index-clear.sh

#/bin/bash
#指定日期(14天前)
DATA=`date -d "2 week ago" +%Y.%m.%d`
#当前日期
time=`date`
#删除14天前的日志
curl -XDELETE http://127.0.0.1:9200/*-${DATA}
if [ $? -eq 0 ];then
echo $time"-->del $DATA log success.." >> /tmp/es-index-clear.log
else
echo $time"-->del $DATA log fail.." >> /tmp/es-index-clear.log
fi

添加到任务计划

crontab -e
10 1 * * * sh /apps/sh/es-index-clear.sh > /dev/null 2>&1
posted @ 2019-07-04 16:40  dream_fly_info  阅读(749)  评论(0编辑  收藏  举报