附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 ...
随机推荐
- 通过jstack与jmap分析一次线上故障
一.发现问题 下面是线上机器的cpu使用率,可以看到从4月8日开始,随着时间cpu使用率在逐步增高,最终使用率达到100%导致线上服务不可用,后面重启了机器后恢复. 二.排查思路 简单分析下可能出问题 ...
- jvm 参数配置优化
abtest业务线上接口每分钟执行3万多次,到半夜1点多访问量小的时候会经常报内存占比过高, 经调研分析发现与白天访问量高时线程数.cpu等无太大差异,主要差异存在内存会涨到很高并持续 一段时间. 现 ...
- 3143 二叉树的序遍历codevs
题目描述 Description 求一棵二叉树的前序遍历,中序遍历和后序遍历 输入描述 Input Description 第一行一个整数n,表示这棵树的节点个数. 接下来n行每行2个整数L和R.第i ...
- BZOJ.3998.[TJOI2015]弦论(后缀自动机)
题目链接 \(Description\) 给定字符串S,求其第K小子串.(若T=0,不同位置的相同子串算1个:否则算作多个) \(Solution\) 建SAM,处理出对于每个节点,它和它的所有后继包 ...
- BZOJ 1009 HNOI 2008 GT考试 递推+矩乘
1009: [HNOI2008]GT考试 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 3679 Solved: 2254[Submit][Statu ...
- Codeforces Round #396 (Div. 2) C. Mahmoud and a Message dp
C. Mahmoud and a Message 题目连接: http://codeforces.com/contest/766/problem/C Description Mahmoud wrote ...
- Ubuntu下实现软路由(转)
参考:http://www.openwrt.pro/post-292.html 个人看法: 1.实现路由在Linux下必须要用到iptables进行转发,这才是路由核心. 2.我觉得对于Linux来说 ...
- Fiddler可以支持Websocket抓包了
今天试了一下,Fiddler已经可以支持客户端Websocket抓包了,并且查看的方式也非常方便. websocket作为一个标准的应用层的协议,在CS端程序用起来也比传统的tcp协议方便了,比较常见 ...
- poj2115
构造出模线性方程c * x = b - a mod (2 ^ k) 很容易解. 利用LRJ书上的方法. #include <iostream> using namespace std; # ...
- Revit API取得系统族普通族几何信息的方法
系统族,可以直接转化为对应的类(Wall,Duct)然后取得几何信息,普通族需要转化为FamilyInstance )) { TaskDialog.Show() ...