# Getting task status in painless script

**URL:** <https://discuss.elastic.co/t/getting-task-status-in-painless-script/286123>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [October 7, 2021, 11:51am UTC](https://discuss.elastic.co/t/getting-task-status-in-painless-script/286123 "2021-10-07T11:51:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Himanshu\_Mishra1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himanshu_mishra1/32/95549_2.png) [@Himanshu\_Mishra1](https://discuss.elastic.co/u/Himanshu_Mishra1)\
**Post date:** [October 7, 2021, 11:51am UTC](https://discuss.elastic.co/t/getting-task-status-in-painless-script/286123/1 "2021-10-07T11:51:14Z")

</div>

Hi Team,

I am using ES 6.8.7.

I am trying to avoid parallel execution of long running \_update\_by\_query requests in Elasticsearch as they are CPU and Memory intensive. I want to make sure that the next task is kept in sleep state until previous is done so that a queue of such tasks is built within ES itself.

For this my plan is to,

- Send one task and get the task id
- In next task, I will check using painless script if task against the above task id is still running. If so, keep the current task sleeping for the completion of previous
- As soon as, the script knows that the task is completed, it will start its work.

Please help me if there is a possible solution to the second step in above.

Thanks in Advance!!!

---

<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:** [November 4, 2021, 11:52am UTC](https://discuss.elastic.co/t/getting-task-status-in-painless-script/286123/2 "2021-11-04T11:52:06Z")

</div>

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