Elastic curator in cron job?


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?


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.

Thanks for your time @theuntergeek

* * * * * /home/hero/.curator/curator --dry-run --config curator.yml delete
.yml >> /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?


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.

Thanks .. It really helped

* * * * * /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?


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

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.


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?



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.

yeah..i figured it out..

THANKS for letting me know that

it really helped..

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