# Execute a recipe on multiple nodes sequentially

**URL:** <https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397>\
**Category:** Chef Automate\
**Created:** [February 13, 2017, 7:06am UTC](https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397 "2017-02-13T07:06:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakki](https://avatars.discourse-cdn.com/v4/letter/l/bc8723/32.png) [@lakki](https://discourse.chef.io/u/lakki)\
**Post date:** [February 13, 2017, 7:06am UTC](https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397/1 "2017-02-13T07:06:45Z")

</div>

Hi Guys, Good morning all.

Recently we have integrated push-jobs with chef to execute recipes from workstation itself. But here my question is how to execute single recipe on multiple nodes sequentially using push-jobs?.

Generally we can execute a recipe on a node with push-jobs using below command  
knife job start ‘chef-client’ node-name (on one node).  
but if i use like below command

knife job start ‘chef-client’ Node1 Node2 Node3 … the recipe executing on multiple nodes but it is executing parallelly on the multiple nodes.

Thanks in Advance…

---

<div class="post-metadata">

**Author:** ![anadkarni](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anadkarni](https://discourse.chef.io/u/anadkarni)\
**Post date:** [January 28, 2020, 4:30am UTC](https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397/2 "2020-01-28T04:30:41Z")

</div>

Did you find solution for this problem?

---

<div class="post-metadata">

**Author:** ![lakki](https://avatars.discourse-cdn.com/v4/letter/l/bc8723/32.png) [@lakki](https://discourse.chef.io/u/lakki)\
**Post date:** [February 6, 2020, 8:25am UTC](https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397/3 "2020-02-06T08:25:55Z")

</div>

No, didn't find a way. Do you have any solution for this.

---

<div class="post-metadata">

**Author:** ![anadkarni](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anadkarni](https://discourse.chef.io/u/anadkarni)\
**Post date:** [February 7, 2020, 7:44pm UTC](https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397/4 "2020-02-07T19:44:25Z")

</div>

No. we are just doing it in for loop  
for node in (knife search "chef\_environment:{environment} AND (role:zookeeper-platform)" | grep FQDN | cut -f2 -d":")  
do  
echo $node  
knife job start chef\_client node -q '1' if [[( "{ACTION}" == "restart" ) && ( -z "${DRYRUN}" )]]  
then  
echo "restarting zookeeper"  
knife job start restart\_zookeeper $node -q '1'  
sleep 10  
fi  
done

---

<div class="post-metadata">

**Author:** ![prashi89](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@prashi89](https://discourse.chef.io/u/prashi89)\
**Post date:** [February 9, 2020, 2:37am UTC](https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397/5 "2020-02-09T02:37:06Z")

</div>

may i know from where you are executing this for loop ?

---

<div class="post-metadata">

**Author:** ![anadkarni](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@anadkarni](https://discourse.chef.io/u/anadkarni)\
**Post date:** [February 11, 2020, 10:12pm UTC](https://discourse.chef.io/t/execute-a-recipe-on-multiple-nodes-sequentially/10397/6 "2020-02-11T22:12:43Z")

</div>

its inside shell script. we can run it from chef workstation.
