# Running chef-client on node through shell script

**URL:** <https://discourse.chef.io/t/running-chef-client-on-node-through-shell-script/12975>\
**Category:** Chef Infra (archive)\
**Created:** [April 27, 2018, 6:28am UTC](https://discourse.chef.io/t/running-chef-client-on-node-through-shell-script/12975 "2018-04-27T06:28:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![priyanshu](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@priyanshu](https://discourse.chef.io/u/priyanshu)\
**Post date:** [April 27, 2018, 6:28am UTC](https://discourse.chef.io/t/running-chef-client-on-node-through-shell-script/12975/1 "2018-04-27T06:28:32Z")

</div>

I am trying to run chef client on node remotely by placing knife ssh command in a shell script.  
How can I identify whether chef client executed successfully or it failed for that execution.  
The command i am using to run chef client remotely through a shell script is:-  
knife ssh -m “nodename” ‘sudo chef-client’

---

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/spuder/32/1382_2.png) [@spuder](https://discourse.chef.io/u/spuder)\
**Post date:** [April 27, 2018, 3:26pm UTC](https://discourse.chef.io/t/running-chef-client-on-node-through-shell-script/12975/2 "2018-04-27T15:26:52Z")

</div>

You should be able to use the `--exit-on-error` option

```
knife ssh -m 'nodename' 'sudo chef-client' --exit-on-error
echo $?
```

---

<div class="post-metadata">

**Author:** ![priyanshu](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@priyanshu](https://discourse.chef.io/u/priyanshu)\
**Post date:** [May 1, 2018, 7:20am UTC](https://discourse.chef.io/t/running-chef-client-on-node-through-shell-script/12975/3 "2018-05-01T07:20:18Z")

</div>

My objective is to update the master table based on the result that if the chef-client execution was successfull then update the table with success else failure.  
Will this command be able to do so?

Now the scenario is , i am passing multiple node names in knife ssh -m “node1,node2” so if chef-client succeeds on node 1 but fails on node 2 so will this --exit-on-error option tell me that it failed on node 2 and passed on node 1
