# Elastic curator in cron job?

**URL:** <https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139>\
**Category:** Elasticsearch\
**Created:** [March 27, 2017, 1:33pm UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139 "2017-03-27T13:33:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [March 27, 2017, 1:33pm UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/1 "2017-03-27T13:33:38Z")

</div>

Hi,

i have curator in linux environment which is in live so i can't experiment with that . i need one clarification regarding the command

i have curator files in `/home/hero/.curator` . If i run the below cron job command whether it will run in dry-run mode correctly or it will delete the indices in the live environment.

```
* * * * * /home/hero/.curator/curator --dry-run --config curator.yml delete
.yml >> /home/hero/.curator/log.txt

```

And also i want to know whether the command is correct or not, because i am sending the cron job logs to log.txt?

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 27, 2017, 3:31pm UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/2 "2017-03-27T15:31:38Z")

</div>

If you're using the `--dry-run` flag in the cron job, it will still be a dry run. No changes will be made.

As far as logging is concerned, that will depend on how you have logging set in your `curator.yml` file. If it's unset, then yes, your logs will go to `/home/hero/.curator/log.txt`. If you have chosen a log file in the configuration, then that's where your log files will go.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [March 27, 2017, 3:36pm UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/3 "2017-03-27T15:36:34Z")

</div>

Thanks for your time @theuntergeek

```
* * * * * /home/hero/.curator/curator --dry-run --config curator.yml delete
.yml &gt;&gt; /home/hero/.curator/log.txt

```

Is it is good approach to send the command like this in cron job or i have to wrap it a bash script?

If it is script how i have to wrap it ? Can you pls give me a example for above scenario?

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 27, 2017, 3:40pm UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/4 "2017-03-27T15:40:20Z")

</div>

It's totally fine to send the entire command in cron, just like you have here. The older, Curator v3 approach had very long command lines, which could sometimes cause errors in cron. You shouldn't have that problem with the current version of Curator.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [March 27, 2017, 3:43pm UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/5 "2017-03-27T15:43:48Z")

</div>

Thanks .. It really helped

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [March 28, 2017, 7:55am UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/6 "2017-03-28T07:55:01Z")

</div>

```
* * * * * /home/hero/.curator/curator --dry-run --config curator.yml delete
.yml >> /home/hero/.curator/log.txt

```

When i used the above command in crontab it is creating a log.txt but nothing is there in it. It is creating an empty file ?

How to solve this?

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:** [March 28, 2017, 7:57am UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/7 "2017-03-28T07:57:21Z")

</div>

Is Curator writing its output to stdout or stderr? As configured you're only capturing stdout to the file.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [March 28, 2017, 8:05am UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/8 "2017-03-28T08:05:50Z")

</div>

Thanks for fast reponse

When i executed the below command manually it am getting status

```
hero@1423:~/.curator$ curator --dry-run --config curator.yml create.yml >> log.txt
hero@1423:~/.curator$ cat log.txt
2017-03-28 07:59:54,071 INFO Preparing Action ID: 1, "create_index"
2017-03-28 07:59:54,082 INFO Trying Action ID: 1, "create_index": Create the index as named, with the specified extra settings.
2017-03-28 07:59:54,082 INFO DRY-RUN MODE. No changes will be made.
2017-03-28 07:59:54,082 INFO DRY-RUN: create_index "myindex" with arguments: {}
2017-03-28 07:59:54,082 INFO Action ID: 1, "create_index" completed.
2017-03-28 07:59:54,082 INFO Job completed.

```

When i did the same thing in cron tab using the above command it is showing empty log.txt file.

Thanks

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [March 28, 2017, 8:15am UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/9 "2017-03-28T08:15:34Z")

</div>

i tried by appending 2\>&1 at the end of command now i am getting like this:

`/bin/sh: 1: /home/hero/.curator/curator: not found`

Is the problem with the path i am giving?

Thanks

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [March 28, 2017, 8:41am UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/10 "2017-03-28T08:41:52Z")

</div>

Hi,

Here my command in cron file and it work:

`0 12 * * * myuser /usr/local/bin/curator --config /home/hero/.curator/curator.yml /home/hero/.curator/action_ranking.yml >> /home/hero/cron_log/curator_ranking.log 2>&1`

I put the full path and 2\>&1 at the end to make it write in the log file.

Hope it can help.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [March 28, 2017, 9:10am UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/11 "2017-03-28T09:10:37Z")

</div>

yeah..i figured it out..

THANKS for letting me know that

it really helped..

---

<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 25, 2017, 9:10am UTC](https://discuss.elastic.co/t/elastic-curator-in-cron-job/80139/12 "2017-04-25T09:10:38Z")

</div>

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