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
相關文章
相關標籤/搜索