# Script – Remove Indices from x Days Ago

**URL:** <https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534>\
**Category:** Elasticsearch\
**Created:** [June 21, 2016, 3:59pm UTC](https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534 "2016-06-21T15:59:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben19](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben19/32/3745_2.png) [@Ben19](https://discuss.elastic.co/u/Ben19)\
**Post date:** [June 21, 2016, 3:59pm UTC](https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534/1 "2016-06-21T15:59:21Z")

</div>

Hello,

We’re looking to develop a rest script that we can run to  
remove any indices before x amount of days, this is required for log retention policies.

We run logstash from Ubuntu servers and can handle the bash scripts  
but wanting assistance creating some restful queries to perform this.

Indices are created as “[logstash-]YYYY.MM.DD”

Cluster name: elasticsearch

Thanks.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [June 21, 2016, 4:08pm UTC](https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534/2 "2016-06-21T16:08:07Z")

</div>

You can use Elasticsearch Curator, a python script designed exactly for this 🙂

> **[elastic/curator](https://github.com/elastic/curator)**
>
> curator - Curator: Tending your Elasticsearch indices

---

<div class="post-metadata">

**Author:** ![Ben19](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben19/32/3745_2.png) [@Ben19](https://discuss.elastic.co/u/Ben19)\
**Post date:** [June 23, 2016, 10:11am UTC](https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534/3 "2016-06-23T10:11:04Z")

</div>

Thanks I'll give that a go.

---

<div class="post-metadata">

**Author:** ![Ben19](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben19/32/3745_2.png) [@Ben19](https://discuss.elastic.co/u/Ben19)\
**Post date:** [June 23, 2016, 3:19pm UTC](https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534/4 "2016-06-23T15:19:52Z")

</div>

Thanks, this worked for me and was able to script it into a  
bash file.

Can curator be used to retrieve documents or just indices?

---

<div class="post-metadata">

**Author:** ![Ben19](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben19/32/3745_2.png) [@Ben19](https://discuss.elastic.co/u/Ben19)\
**Post date:** [July 20, 2016, 10:59am UTC](https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534/5 "2016-07-20T10:59:42Z")

</div>

Anyone recomend a method for my last question? Thanks.

---

<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:34pm UTC](https://discuss.elastic.co/t/script-remove-indices-from-x-days-ago/53534/6 "2017-07-05T22:34:06Z")

</div>


