elasticsearch的索引清理

 

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

 

脚本加api删除(推荐)api

cat es-index-clear.shbash

#/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

添加到任务计划app

crontab -e
10 1 * * * sh /apps/sh/es-index-clear.sh > /dev/ null  2>&1
相关文章
相关标签/搜索