美文网首页
定期清理es索引

定期清理es索引

作者: 野草_疯长 | 来源:发表于2019-07-23 15:08 被阅读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
    

    相关文章

      网友评论

          本文标题:定期清理es索引

          本文链接:https://www.haomeiwen.com/subject/gvzolctx.html