# Delete index at a regular basis

**URL:** https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621
**Category:** Elasticsearch
**Created:** [July 4, 2016, 8:41am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621 "2016-07-04T08:41:37Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)
#### Post date: [July 4, 2016, 8:41am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/1 "2016-07-04T08:41:37Z")

</div>

I have made different kinds of indexes into ES and everytime I want to delete some old indexes, I need to write the currator command to delete old indices. Even though I have read through the examples from [https://www.elastic.co/guide/en/elasticsearch/client/curator/current/examples.html](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/examples.html), I still do not quite understand how can I follow them. Would anyone can tell me how can I make ES to regularly delete old indices automatically?

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [July 4, 2016, 8:55am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/2 "2016-07-04T08:55:07Z")

</div>

The page you link to contains an example of how to delete old indexes: [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/examples.html#ex_delete_indices)

If this doesn't work for you please describe in what way it doesn't work. Providing Curator logs would probably make it easier to help.

---

<div class="post-metadata">

### Author: ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)
#### Post date: [July 4, 2016, 10:20am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/3 "2016-07-04T10:20:51Z")

</div>

I am originally using curator 3.5.1 but then I have upgraded to curator 4. However I could not find where curator is stored. Therefore, I would wanna know where will the configuration file be and why there will be a missing of action\_file?

Here aresome screenshots for reference:  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/d/d75f20b638c12f852fe6fea1c294fce8e632207f.png)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/f/fdf0cf02d58e7e32616bec164454ec6ed508d7b8.png)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/d/d077bbc89dd1b0c9e7e68bb58812d0fdb644af26.png)

Great thanks in advance for telling where would the file be.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [July 4, 2016, 10:46am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/4 "2016-07-04T10:46:19Z")

</div>

Please don't post screenshots of text that can be copied and pasted.

The action file is a YAML file containing the actions to execute, as found in the examples we talked about earlier. You can store your action file anywhere.

---

<div class="post-metadata">

### Author: ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)
#### Post date: [July 4, 2016, 10:54am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/5 "2016-07-04T10:54:42Z")

</div>

Sorry for the screenshots part.

Does that mean I need to create a new .curator directory and also my own curator.yml and action.yml file?

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [July 4, 2016, 11:21am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/6 "2016-07-04T11:21:41Z")

</div>

You can place curator.yml and action.yml anywhere you want and give them any name, but if you call the configuration file ~/.curator/curator.yml you won't have to use the `--config` option since the default will work. See [https://www.elastic.co/guide/en/elasticsearch/client/curator/4.0/configfile.html](https://www.elastic.co/guide/en/elasticsearch/client/curator/4.0/configfile.html) for more information about the configuration file.

---

<div class="post-metadata">

### Author: ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)
#### Post date: [July 7, 2016, 3:28am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/7 "2016-07-07T03:28:33Z")

</div>

Hi @magnusbaeck,

Thanks for your answer and sorry for a late reply. I have tried creating the curator and action yaml file. However, following the example, it can only filter named index by typing the wanted-to-delete index name in the **value** field. How about if I want to delete any index that is older than 5 days? How can I do so?

And, how can I make the curator to run regularly on a daily basis?

Thanks.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [July 7, 2016, 5:34am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/8 "2016-07-07T05:34:45Z")

</div>

> However, following the example, it can only filter named index by typing the wanted-to-delete index name in the value field. How about if I want to delete any index that is older than 5 days? How can I do so?

I'm not sure what example you've been following, but the documentation's `delete_indices` example, [Examples | Curator Reference [4.0] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/curator/4.0/examples.html#ex_delete_indices), shows how to delete indices older than 45 days.

> And, how can I make the curator to run regularly on a daily basis?

Use cron.

---

<div class="post-metadata">

### Author: ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)
#### Post date: [July 7, 2016, 5:50am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/9 "2016-07-07T05:50:01Z")

</div>

Hi @magnusbaeck  
Thanks for the reply. I have followed exactly the same link where you embedded but from that example, it can only delete with index that start with `logstash-`. Thus, I would wonder how to delete any index that older than 5 days?

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [July 7, 2016, 5:54am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/10 "2016-07-07T05:54:45Z")

</div>

This part makes sure the deletion action only applies to indices older than 45 days:

```auto
- filtertype: age
  source: name
  direction: older
  timestring: '%Y.%m.%d'
  unit: days
  unit_count: 45
  exclude:

```

Over and out.

---

<div class="post-metadata">

### Author: ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)
#### Post date: [July 7, 2016, 6:06am UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/11 "2016-07-07T06:06:38Z")

</div>

Hi @magnusbaeck  
Thanks. I am able to solve it now.

---

<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: [July 5, 2017, 10:37pm UTC](https://discuss.elastic.co/t/delete-index-at-a-regular-basis/54621/12 "2017-07-05T22:37:26Z")

</div>


