附9 elasticsearch-curator + Linux定时任务
官网教程入口: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,必须得有
说明:
- 例子:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/examples.html#ex_delete_indices
- https://www.elastic.co/guide/en/elasticsearch/client/curator/current/actionfile.html
三、测试
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定时任务的更多相关文章
- 【附9】elasticsearch-curator + Linux定时任务
官网教程入口:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html 一.下载安装 下载:sud ...
- linux定时任务crond export变量问题
linux定时任务crond export变量问题 1)我写了一个重启resin的脚本,由于业务原因,需要定时在某一个时间重启下resin服务器,于是就在 crontab里配置了如下内容: 50 17 ...
- Linux 定时任务
200 ? "200px" : this.width)!important;} --> 介绍 本篇主要介绍Linux定时任务命令crontab的用法,crontab是定时任务 ...
- Linux 定时任务 Crontab命令 详解
前言 crontab是Unix和Linux用于设置周期性被执行的指令,是互联网很常用的技术,很多任务都会设置在crontab循环执行,如果不使用crontab,那么任务就是常驻程序,这对你的程序要求比 ...
- 如何让Linux定时任务crond以秒为单位执行(如每隔3秒)
需要用到Shell脚本每隔3秒钟去监控一个软件进程的运行状态,发现crond似乎只支持到分,不知道秒,怎么办呢? 第一种方法: 当然首先想到的是写一个触发的脚本,在触发脚本中使用死循环来解决此问题,如 ...
- 工作中linux定时任务的设置及相关配置
工作中会用到定时任务,来处理以前采集来的数据备份, 每周一凌晨4点执行一次 0 4 * * */1 find/data/templatecdr/oracle/dcndatabak/ -type ...
- 如何让linux定时任务crontab按秒执行
如何让linux定时任务crontab按秒执行? linux定时任务crontab最小执行时间单位为分钟如果想以秒为单位执行,应该如何设置呢?思路 正常情况是在crontab中直接定义要执行的任务,现 ...
- (转载)Linux定时任务cron配置
(转载)http://blog.csdn.net/jbgtwang/article/details/7995801 实现linux定时任务有:cron.anacron.at等,这里主要介绍cron服务 ...
- linux定时任务crontab的设置
linux定时任务crontab的设置http://www.blogjava.net/freeman1984/archive/2010/09/23/332715.html vi /etc/cronta ...
随机推荐
- 【Ray Tracing The Next Week 超详解】 光线追踪2-3
Preface 终于到了激动人心的纹理章节了 然鹅,看了下,并不激动 因为我们之前就接触过 当初有一个 attenuation 吗? 对了,这就是我们的rgb分量过滤器,我们画出的红色.蓝色.绿色等 ...
- [代码审计]云ec电商系统代码审计
0x00 前言 看了一下博客内最新的文章,竟然是3月28号的,一个多月没写文章了,博客都长草了. 主要是临近毕业,事情繁多,也没有啥时间和心情静下来写.. 不过现在的话,毕业的东西告一段落了,几乎没啥 ...
- SQL语句之 多表管理
SQL语句之 多表管理 一个数据库内通常会有不止一张表,有时候我们要把多张表联系起来,这就需要用到多表管理的语句. 1.外键约束 一个表中的非主键字段,如果在另外一张表中是主键,那么这个字段我们叫它做 ...
- jsonp的理解
众所周知:在开发过程中,有时候需要客户端从服务器接收或向服务器发送一些数据:如果使用普通的ajax,则会遇到跨域访问无权限的问题. 要解决这个问题,就需要了解一下jsonp了: 1. ajax请求普通 ...
- 清北学堂省选刷题冲刺班 Test Day3
目录 2018.3.27 Test T1 T2 T3 考试代码 T2 T3 2018.3.27 Test 时间:8:00~11:30 期望得分:100+60+25=185 实际得分:100+40+25 ...
- 最新的裸机联想笔记本装win7系统/SSD(固态硬盘)上安装win7系统/联想K4450A i7装win7系统
老师让我帮他装个操作系统,由于是新电脑,并且老师的电脑上另安有固态硬盘,老师要我把系统安装在固态硬盘上,BIOS是2014年7月份的,所以BIOS设置项可能会有所变化. 下面是遇到的一些问题,及解决方 ...
- Linux学习笔记08—如何关闭防火墙
Linux系统下面自带了防火墙iptables,iptables可以设置很多安全规则.但是如果配置错误很容易导致各种网络问题,那么如果要关闭禁用防火墙怎么操作呢,咗嚛本经验以centos系统为例演示如 ...
- ROS知识(21)----ROS C++代码格式化
这里提供两种方法. 第一种方法:clang_format 1.安装clang format sudo apt-get install -y clang-format-3.6 2.从github的ros ...
- [Deepin 15] sudo source /etc/profile 提示找不到 source 命令(切换到 root 用户:sudo su)
在 Deepin/Ubuntu 系统 中,因为修改了下 配置文件,然后执行 source 命令重新加载配置文件,结果: sudo source /etc/profile 提示找不到 source 命令 ...
- PHP 如何创建守护(daemon)进程
先讲几个概念 守护进程: Linux中的后台服务进程.它是一个生存期较长的进程,通常独立于控制终端并且周期性地执行某种任务或等待处理某些发生的事件.守护进程常常在系统引导装入时启动,在系统关闭时终止. ...