# Execute policy synchronously without a \`sleep\` in my bash scripts

**URL:** <https://discuss.elastic.co/t/execute-policy-synchronously-without-a-sleep-in-my-bash-scripts/323695>\
**Category:** Elasticsearch\
**Created:** [January 23, 2023, 2:44am UTC](https://discuss.elastic.co/t/execute-policy-synchronously-without-a-sleep-in-my-bash-scripts/323695 "2023-01-23T02:44:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![learningelastic](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@learningelastic](https://discuss.elastic.co/u/learningelastic)\
**Post date:** [January 23, 2023, 2:44am UTC](https://discuss.elastic.co/t/execute-policy-synchronously-without-a-sleep-in-my-bash-scripts/323695/1 "2023-01-23T02:44:41Z")

</div>

I've been following this guide to learn how to use enrich processor and ingestion pipelines:

> **[Enrich your data | Elasticsearch Guide \[8.6\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-enriching-data.html)**

I've got most things working so I tried a more realistic workflow that goes something like this:

```auto

#!/bin/bash

/usr/share/logstash/bin/logstash -e 'input {file {path="/home/user/foo.csv"} } output { elasticsearch {...connection details...}}'

curl -X PUT -u elastic:mypass "https://example.com:9200/_enrich/policy/foo-policy" \
-H "Content-Type: application/json" \
-d "...some policy that depends on the `foo` index..."

sleep 60

curl -X PUT -u elastic:mypass "https://example.com:9200/_enrich/policy/foo-policy/_execute"

# ...define some pipelines that use my `foo-policy` and then use the pipelines...

```

Everything above works fine. But if I remove the line `sleep 60`, then my pipelines fail to enrich any data from the `foo` policy.

From what I can tell, after logstash has sent data to elastic, elastic still needs time to process them and store them. If I run my `foo-policy/_execute` too early, then the `foo` data won't be available for ingestion pipelines further down in my workflow.

Is there a way to tell elastic to `foo-policy/_execute` only after it has processed my latest batch of data?

---

<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:** [February 20, 2023, 2:45am UTC](https://discuss.elastic.co/t/execute-policy-synchronously-without-a-sleep-in-my-bash-scripts/323695/2 "2023-02-20T02:45:15Z")

</div>

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