# Regarding to curator delete indices older than 5 days

**URL:** https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073
**Category:** Elasticsearch
**Created:** [February 22, 2017, 3:34pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073 "2017-02-22T15:34:58Z")
**Posts on this page:** 8
**Page:** 2

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [February 24, 2017, 6:38pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/21 "2017-02-24T18:38:33Z")

</div>

I'd verify that with `--dry-run` first.

---

<div class="post-metadata">

### Author: ![Ximeng\_Zhao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ximeng_zhao/32/15775_2.png) [@Ximeng\_Zhao](https://discuss.elastic.co/u/Ximeng_Zhao)
#### Post date: [March 3, 2017, 3:33pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/22 "2017-03-03T15:33:01Z")

</div>

Hi Aaron, I need to create a script to delete indices older than 3 months, I have viewed those indices name, for instance: user, logstash-2014-09-08, student...

As u can see, their name is defined in different format, but I just need to delete indices older than 3 months,  
How can I write the filters? Here's what I wrote down for one specific index name 'user', how to change the first filtertype to work for all types of indices name? Thank you for your instruction.

filters:

- filtertype: pattern  
kind: regex  
value: '^user$'  
exclude:
- filtertype: age  
source: creation\_date  
direction: older  
unit: months  
unit\_count: 3  
exclude:

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [March 3, 2017, 4:01pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/23 "2017-03-03T16:01:40Z")

</div>

If you are deleting indices by age, with no regard for name, then you can omit the `filtertype: pattern` portion from the filters. However, as mentioned, you will want to run this with `--dry-run` first to make sure it's not deleting things you might not want deleted, like the `.kibana` index.

---

<div class="post-metadata">

### Author: ![Ximeng\_Zhao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ximeng_zhao/32/15775_2.png) [@Ximeng\_Zhao](https://discuss.elastic.co/u/Ximeng_Zhao)
#### Post date: [March 3, 2017, 4:12pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/24 "2017-03-03T16:12:25Z")

</div>

Thanks, and one more question is since now every time I need to update my action.yml to implement indices deletion, just want to understand how to automatically delete data after certain days? On what criteria can the data be deleted? Thanks.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [March 3, 2017, 4:20pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/25 "2017-03-03T16:20:58Z")

</div>

In Unix-like systems, you would execute your curator command line in cron:

```auto
0 2 * * * /usr/bin/curator --config MYCONFIG.YML ACTIONFILE.YML

```

This will run Curator every day at 2am (server time).

In Windows, you would need to use the task scheduler, or some app that provides similar functionality.

---

<div class="post-metadata">

### Author: ![Ximeng\_Zhao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ximeng_zhao/32/15775_2.png) [@Ximeng\_Zhao](https://discuss.elastic.co/u/Ximeng_Zhao)
#### Post date: [March 6, 2017, 8:27pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/26 "2017-03-06T20:27:02Z")

</div>

Hi Aaron,

I want to delete all indices based on the creation date except .kibana. I have used --dry-run to verify that, but it seems like it's not correct to implement that using the following scripts, any ideas about my script? Thanks.

actions:  
1:  
action: delete\_indices  
description: "Delete indices older than 5 days (based on index name)  
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:kibana  
exclude:False  
- filtertype: age  
source: creation\_date  
direction: older  
unit: days  
unit\_count: 5  
exclude:

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [March 7, 2017, 2:16pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/27 "2017-03-07T14:16:35Z")

</div>

Please start a new topic with that question, as the original question was answered.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 4, 2017, 2:16pm UTC](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073/28 "2017-04-04T14:16:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

[Previous page](https://discuss.elastic.co/t/regarding-to-curator-delete-indices-older-than-5-days/76073.md?page=1)
