官网教程入口:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html

一、下载安装

  • 下载:sudo pip install elasticsearch-curator
  • 更新:sudo pip install -U elasticsearch-curator

版本:curator4.1.0

二、配置文件

1、config.yml

# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
client:
  hosts: ["127.0.0.1:9200"]
  url_prefix:
  use_ssl: False
  certificate:
  client_cert:
  client_key:
  aws_key:
  aws_secret_key:
  aws_region:
  ssl_no_validate: False
  http_auth:
  timeout: 30
  master_only: False

logging:
  loglevel: INFO
  logfile:
  logformat: default
  blacklist: ['elasticsearch', 'urllib3']

说明:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html

2、action.yml

---
# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True.  If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
  1:
    action: delete_indices
    description: "Delete indices older than 45 days (based on index name), for logstash- prefixed indices.
                  Ignore the error if the filter does not result in an actionable list of indices (ignore_empty_list) and exit cleanly"
    options:
      timeout_override:
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: logstash-
      exclude:
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 5
      exclude:

注意:action上边那个1是action id,必须得有

说明:

三、测试

curator --config ~/Desktop/server/elk/es-curator-4.1.0/config.yml ~/Desktop/server/elk/es-curator-4.1.0/action.yml

四、做成Linux定时任务

1、编写sh脚本:curator-delete-index.sh

#!/bin/sh
/usr/local/bin/curator --config /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/config.yml /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/action.yml
echo "delete index success"

注意:最好使用命令的全路径名,否则可能找不到。

2、赋予权限

  • chmod 777 /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/curator-delete-index.sh

3、创建定时任务:crontab

  • crontab -e:打开了vi,输入:

    • 30 16 * * * /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/curator-delete-index.sh,之后保存退出vi

  • crontab -l:查看所有的root用户的定时任务

附:crontab的文件格式

分 时 日 月 星期 要运行的命令

  • 第1列分钟1~59
  • 第2列小时1~23(0表示子夜)
  • 第3列日1~31
  • 第4列月1~12
  • 第5列星期0~7(0和7表示星期天)
  • 第6列要运行的命令

【附9】elasticsearch-curator + Linux定时任务的更多相关文章

  1. 附9 elasticsearch-curator + Linux定时任务

    官网教程入口:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html 一.下载安装 下载:sud ...

  2. linux定时任务crond export变量问题

    linux定时任务crond export变量问题 1)我写了一个重启resin的脚本,由于业务原因,需要定时在某一个时间重启下resin服务器,于是就在 crontab里配置了如下内容: 50 17 ...

  3. Linux 定时任务

    200 ? "200px" : this.width)!important;} --> 介绍 本篇主要介绍Linux定时任务命令crontab的用法,crontab是定时任务 ...

  4. Linux 定时任务 Crontab命令 详解

    前言 crontab是Unix和Linux用于设置周期性被执行的指令,是互联网很常用的技术,很多任务都会设置在crontab循环执行,如果不使用crontab,那么任务就是常驻程序,这对你的程序要求比 ...

  5. 如何让Linux定时任务crond以秒为单位执行(如每隔3秒)

    需要用到Shell脚本每隔3秒钟去监控一个软件进程的运行状态,发现crond似乎只支持到分,不知道秒,怎么办呢? 第一种方法: 当然首先想到的是写一个触发的脚本,在触发脚本中使用死循环来解决此问题,如 ...

  6. 工作中linux定时任务的设置及相关配置

    工作中会用到定时任务,来处理以前采集来的数据备份, 每周一凌晨4点执行一次    0 4 * * */1 find/data/templatecdr/oracle/dcndatabak/ -type ...

  7. 如何让linux定时任务crontab按秒执行

    如何让linux定时任务crontab按秒执行? linux定时任务crontab最小执行时间单位为分钟如果想以秒为单位执行,应该如何设置呢?思路 正常情况是在crontab中直接定义要执行的任务,现 ...

  8. (转载)Linux定时任务cron配置

    (转载)http://blog.csdn.net/jbgtwang/article/details/7995801 实现linux定时任务有:cron.anacron.at等,这里主要介绍cron服务 ...

  9. linux定时任务crontab的设置

    linux定时任务crontab的设置http://www.blogjava.net/freeman1984/archive/2010/09/23/332715.html vi /etc/cronta ...

随机推荐

  1. compass利用koala在chrome开启scss调试

    compass不生成maps文件,所载调试css上,极不方便.看到下图的调试方式,怎么做. 利用用koala来解决,具体步骤如下: 1.确保自己安装了ruby和sass,compass.接着安装 co ...

  2. requests的post请求:百度翻译

    import json import requests class Trans(object): def __init__(self, juzi): self.juzi = juzi self.bas ...

  3. UVA 11136 Hoax or what (multiset)

    题目大意: 超时进行促销.把账单放入一个箱子里 每次拿取数额最大的和最小的,给出 最大-最小  的钱. 问n天总共要给出多少钱. 思路分析: multiset 上直接进行模拟 注意要使用long lo ...

  4. 001-nginx基础配置-location

    一.基础语法 Location block 的基本语法形式是: location [=|~|~*|^~|@] pattern { ... } [=|~|~*|^~|@] 被称作 location mo ...

  5. Thinkpad机器BIOS下清除安全芯片和指纹数据的方法

    清除安全芯片: 首先在刚开机出现ThinkPad图标时,按F1进入BIOS界面,然后长按关机按钮关机(注意一定是断电的关机,不是重新启动)然后开机再按F1键进入BIOS设置.选择“Securiy”-〉 ...

  6. 正态分布及3Sigma原理

    针对这个问题,用一两句话是难以说清楚的,这是数理统计学的内容,当质量特性呈正态分布时(实际上,当样本足够大时,二项分布.泊松分布等均趋近于正态分布),3Sigma水平代表了99.73%的合格率

  7. js实现轮播图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. centos添加epel源

    1. rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm    粗体部分需要根据自己的 ...

  9. vue框架(二)_vue环境搭建及创建项目

    1.node.js:概念介绍及安装 node.js:是一个基于chrome浏览器的v8引擎,可以运行javascript的环境(平台) 特性:异步IO模型 npm:是一个包管理器(工具),可以按装依赖 ...

  10. mysql套接字文件