dave@cm-log-manager:~/tools$ cat delete_ES_index.sh
yesterday=`/bin/date --date="-1 days" +%Y.%m.%d`
echo $yesterday
twodayago=`/bin/date --date="-2 days" +%Y.%m.%d`
echo $twodayago
curl -XDELETE "http://localhost:9200/logstash-$twodayago"
threedayago=`/bin/date --date="-3 days" +%Y.%m.%d`
echo $threedayago
curl -XDELETE "http://localhost:9200/logstash-$threedayago"
fourdayago=`/bin/date --date="-4 days" +%Y.%m.%d`
echo $fourdayago
curl -XDELETE "http://localhost:9200/logstash-$fourdayago"
fivedayago=`/bin/date --date="-5 days" +%Y.%m.%d`
echo $fivedayago
curl -XDELETE "http://localhost:9200/logstash-$fivedayago"
2, Add this script to cronjob
1 23 * * * /home/dave/tools/delete_ES_index.sh
3, now only two days index left
No comments:
Post a Comment