# Automatically closing indices older than 2 days

**URL:** https://discuss.elastic.co/t/automatically-closing-indices-older-than-2-days/11317
**Category:** Elasticsearch
**Created:** [March 26, 2013, 12:30pm UTC](https://discuss.elastic.co/t/automatically-closing-indices-older-than-2-days/11317 "2013-03-26T12:30:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Vikram\_Shankar](https://avatars.discourse-cdn.com/v4/letter/v/258eb7/32.png) [@Vikram\_Shankar](https://discuss.elastic.co/u/Vikram_Shankar)
#### Post date: [March 26, 2013, 12:30pm UTC](https://discuss.elastic.co/t/automatically-closing-indices-older-than-2-days/11317/1 "2013-03-26T12:30:04Z")

</div>

Hi,

I am trying to add a cron job that will automatically close indices older  
than 2 days(to free up RAM,not enough RAM on nodes )

Here is a brief snippet of the script (in $indexName i have extracted the  
index name)

curlStr="curl -XPOST 'localhost:9200/$indexName/\_close'"  
curl $curlStr

I get the following error when i run the script:  
curl: (6) Couldn't resolve host ''localhost'

I know this has to do with my bash scripting abilities and not ES as such  
🙂 However, i am hoping to get suggestions on how you might be handling  
similar situations? Any solution to the above problem would be nice too 🙂

Thanks in advance,  
Shankar

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Vikram\_Shankar](https://avatars.discourse-cdn.com/v4/letter/v/258eb7/32.png) [@Vikram\_Shankar](https://discuss.elastic.co/u/Vikram_Shankar)
#### Post date: [March 26, 2013, 1:12pm UTC](https://discuss.elastic.co/t/automatically-closing-indices-older-than-2-days/11317/2 "2013-03-26T13:12:11Z")

</div>

On Mar 26, 2013 6:00 PM, "Vikram Shankar" [austinium@gmail.com](mailto:austinium@gmail.com) wrote:

> Hi,
> 
> I am trying to add a cron job that will automatically close indices older  
> than 2 days(to free up RAM,not enough RAM on nodes )
> 
> Here is a brief snippet of the script (in $indexName i have extracted the  
> index name)

Please ignore the error in the string below, the actual string in the  
script doesn't have the extra curl

> curlStr="curl -XPOST 'localhost:9200/$indexName/\_close'"  
> curl $curlStr
> 
> I get the following error when i run the script:  
> curl: (6) Couldn't resolve host ''localhost'
> 
> I know this has to do with my bash scripting abilities and not ES as such  
> 🙂 However, i am hoping to get suggestions on how you might be handling  
> similar situations? Any solution to the above problem would be nice too 🙂
> 
> Thanks in advance,  
> Shankar
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)
#### Post date: [March 27, 2013, 1:51pm UTC](https://discuss.elastic.co/t/automatically-closing-indices-older-than-2-days/11317/3 "2013-03-27T13:51:58Z")

</div>

Hello Vicky,

I'm no bash wizard either, but it's definitely the single quotes that  
bothers it. Something like this should work:  
INDEX="a"  
curlstr="-XPOST localhost:9200/$INDEX/\_close"  
curl $curlstr

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Tue, Mar 26, 2013 at 3:12 PM, Vicky [austinium@gmail.com](mailto:austinium@gmail.com) wrote:

> On Mar 26, 2013 6:00 PM, "Vikram Shankar" [austinium@gmail.com](mailto:austinium@gmail.com) wrote:
> 
> > Hi,
> > 
> > I am trying to add a cron job that will automatically close indices  
> > older than 2 days(to free up RAM,not enough RAM on nodes )
> > 
> > Here is a brief snippet of the script (in $indexName i have extracted  
> > the index name)
> 
> Please ignore the error in the string below, the actual string in the  
> script doesn't have the extra curl
> 
> > curlStr="curl -XPOST 'localhost:9200/$indexName/\_close'"  
> > curl $curlStr
> > 
> > I get the following error when i run the script:  
> > curl: (6) Couldn't resolve host ''localhost'
> > 
> > I know this has to do with my bash scripting abilities and not ES as  
> > such 🙂 However, i am hoping to get suggestions on how you might be  
> > handling similar situations? Any solution to the above problem would be  
> > nice too 🙂
> > 
> > Thanks in advance,  
> > Shankar
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US)  
> > .  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Vikram\_Shankar](https://avatars.discourse-cdn.com/v4/letter/v/258eb7/32.png) [@Vikram\_Shankar](https://discuss.elastic.co/u/Vikram_Shankar)
#### Post date: [March 28, 2013, 11:08am UTC](https://discuss.elastic.co/t/automatically-closing-indices-older-than-2-days/11317/4 "2013-03-28T11:08:44Z")

</div>

Thanks, that fixed it 🙂  
Its strange how it works with the single quotes when run from the command  
line (instead of being run from a script)  
On Mar 27, 2013 7:22 PM, "Radu Gheorghe" [radu.gheorghe@sematext.com](mailto:radu.gheorghe@sematext.com) wrote:

> Hello Vicky,
> 
> I'm no bash wizard either, but it's definitely the single quotes that  
> bothers it. Something like this should work:  
> INDEX="a"  
> curlstr="-XPOST localhost:9200/$INDEX/\_close"  
> curl $curlstr
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> On Tue, Mar 26, 2013 at 3:12 PM, Vicky [austinium@gmail.com](mailto:austinium@gmail.com) wrote:
> 
> > On Mar 26, 2013 6:00 PM, "Vikram Shankar" [austinium@gmail.com](mailto:austinium@gmail.com) wrote:
> > 
> > > Hi,
> > > 
> > > I am trying to add a cron job that will automatically close indices  
> > > older than 2 days(to free up RAM,not enough RAM on nodes )
> > > 
> > > Here is a brief snippet of the script (in $indexName i have extracted  
> > > the index name)
> > 
> > Please ignore the error in the string below, the actual string in the  
> > script doesn't have the extra curl
> > 
> > > curlStr="curl -XPOST 'localhost:9200/$indexName/\_close'"  
> > > curl $curlStr
> > > 
> > > I get the following error when i run the script:  
> > > curl: (6) Couldn't resolve host ''localhost'
> > > 
> > > I know this has to do with my bash scripting abilities and not ES as  
> > > such 🙂 However, i am hoping to get suggestions on how you might be  
> > > handling similar situations? Any solution to the above problem would be  
> > > nice too 🙂
> > > 
> > > Thanks in advance,  
> > > Shankar
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US)  
> > > .  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> > 
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/nJOO03Fstz8/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:43am UTC](https://discuss.elastic.co/t/automatically-closing-indices-older-than-2-days/11317/5 "2017-07-06T02:43:59Z")

</div>


