官网教程入口: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. rabbitmq学习(四) —— 发布订阅

    为了说明这种模式,我们将建立一个简单的日志系统.这个系统将由两个程序组成,第一个将发出日志消息,第二个将接收并处理日志消息.在我们的日志系统中,每一个运行的接收程序的副本都会收到日志消息. 交换器(E ...

  2. Ubuntu 18.04 安装 virtualbox

    1.安装包下载地址 [https://www.virtualbox.org/wiki/Linux_Downloads] 2.进入软件包的文件夹 sudo dpkg -i 安装包的名字.deb [注]如 ...

  3. 我的php.ini上传文件配置

    可以通过phpinfo查看.当前的配置信息 # php -i | grep php.ini              //查看php.ini位置 file_uploads = on          ...

  4. BZOJ4255 : Keep Fit!

    首先旋转坐标系,把每个点可以接收的范围转化成一个正方形. 然后建立k-d tree,并记录下每个点在k-d tree上的位置. 对询问使用莫队算法,修改$O(\log n)$,查询期望$O(\log ...

  5. Codeforces Beta Round #14 (Div. 2) A. Letter 水题

    A. Letter 题目连接: http://www.codeforces.com/contest/14/problem/A Description A boy Bob likes to draw. ...

  6. VGA Signal Timing

    VGA Signal Timing 640 x 350 VGA 640x350@70 Hz (pixel clock 25.175 MHz) VESA 640x350@85 Hz (pixel clo ...

  7. 【权限设计】一个案例,三个角色,简单说下B端产品的权限设计

    入行以来也接触过一些B端产品,这些产品之中权限管理是重中之重,权限管理不仅仅是整个系统的一个小小的模块,它一直贯穿整个系统,从登陆到操作到最后的登出.说它相当的复杂真不为过. 对于权限,如果从控制力来 ...

  8. SQL 查询逻辑处理顺序

    http://www.cnblogs.com/lyhabc/articles/3912608.html http://blog.csdn.net/lanxu_yy/article/details/62 ...

  9. [Winform]在关闭程序后,托盘不会消失的问题

    摘要 在开发winform程序时,添加了系统托盘,然发现在程序关闭后,托盘并不会消失,鼠标放在上面之后,才会消失.猜测是资源没有释放干净引起的.托盘作为form的组件,应该会随着form的关闭而释放啊 ...

  10. Net Framework 2.0 MSI returned error code 1603解决方法

    出现这种情况的原因,主要是用ghost做的系统,有很多系统中把ie给绑架了.下面的截图就是ghost做的系统中注册表的显示,通过上面的方法就可以解决这种Microsoft .NET Framework ...