# How to stop an exec Node, run another exec Node and when it's finished rerun the first

**URL:** https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416
**Category:** General
**Created:** [17 August 2019 08:29 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416 "2019-08-17T08:29:31Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![HilalAlHakani1](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@HilalAlHakani1](https://discourse.nodered.org/u/HilalAlHakani1)
#### Post date: [17 August 2019 08:29 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/1 "2019-08-17T08:29:31Z")

</div>

Hello  
i'm new to Node Red , i'm working with a Lora Gps Hat.  
i have raspberry C code to send Data and another to receive data . the Lora hat can't be receiving and emitting at the same time  
i have tested the exec Node to send data it's working perfectly  
and i used a daemon Node to receive data also it's working

what i like to do is when i need to send data from the pi to the Arduino  
i want to stop the receiving daemon node ,run the send exec node , then rerun the receiving daemon node

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [17 August 2019 08:59 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/2 "2019-08-17T08:59:08Z")

</div>

The daemon node can auto restart after being stopped. So you could kill it. Do the transmit an let it restart

---

<div class="post-metadata">

### Author: ![HilalAlHakani1](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@HilalAlHakani1](https://discourse.nodered.org/u/HilalAlHakani1)
#### Post date: [17 August 2019 09:45 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/3 "2019-08-17T09:45:36Z")

</div>

Thanks for the answer ,  
but it will launch straight after sending this to it to its input .

delete msg.payload;  
msg.kill="SIGKILL";  
return msg;.

. there isn't a delay to launch it when it has an error ..

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [17 August 2019 11:52 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/4 "2019-08-17T11:52:23Z")

</div>

> [@HilalAlHakani1](#):
>
> the Lora hat can't be receiving and emitting at the same time

You'll have to forgive my ignorance I have no idea what a lora hat is. But ... I don't understand what you mean when you say can't be receiving and sending at same time & therefore you have 2 C applications?

Can't your application just close and open ports without quitting?

What protocol is this? Isn't there a node-red node than can communicate with this device? Or perhaps a nodejs module you could build a node-red node from?

Are there no other options like adding MQTT into the mix for inter-device communication?

---

<div class="post-metadata">

### Author: ![HilalAlHakani1](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@HilalAlHakani1](https://discourse.nodered.org/u/HilalAlHakani1)
#### Post date: [17 August 2019 12:18 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/5 "2019-08-17T12:18:48Z")

</div>

Dear Steve ,  
Thanks for reaching out , Lora is a type of modulation (Physical layer in the Osi Model) to send and receive data over large distance with minimum power .. the Lora hat is a board with an antenna that gets plugged to the raspbery Pi that supports Lora .  
i'm using this code [https://github.com/dragino/rpi-lora-tranceiver/tree/master/dragino\_lora\_app](https://github.com/dragino/rpi-lora-tranceiver/tree/master/dragino_lora_app)  
for the raspberry pi..  
i have 1 code that can be either receiving or either sending .. from argv1 if i send data to it i will be sending if not i will be receiving.

as for the mqtt part , it will be also for sending and receiving from mobile to the hat that will be also sending and receiving for the arduinos

i didn't manage a way to edit the C code (it's the official code for the board)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [17 August 2019 12:34 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/6 "2019-08-17T12:34:58Z")

</div>

So that code it seems is written to read command line and based on the command line arg, operate exclusively as a sender or receiver.

I see no reason why you can't switch between these modes without quitting (obviously some modifications to code & testing would be required).

Additionally, at a quick glance, all communication to the board appears to be SPI. I believe there are node-red nodes for communicating over SPI. so (speaking from zero experience) it seams using the code you linked to, you could figure out the various commands and constants required to do this without any C code. All in node-red/nodejs

Just a thought.

Sorry I can't be of more help.

---

<div class="post-metadata">

### Author: ![HilalAlHakani1](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@HilalAlHakani1](https://discourse.nodered.org/u/HilalAlHakani1)
#### Post date: [17 August 2019 16:44 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/7 "2019-08-17T16:44:05Z")

</div>

thanks for your help i'll see what i will do

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [17 August 2019 17:58 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/8 "2019-08-17T17:58:02Z")

</div>

By default the daemon node has a 10 second pause before restarting. So if you kill it it should give you time to fire your transmit.

---

<div class="post-metadata">

### Author: ![HilalAlHakani1](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@HilalAlHakani1](https://discourse.nodered.org/u/HilalAlHakani1)
#### Post date: [4 September 2019 18:26 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/9 "2019-09-04T18:26:10Z")

</div>

it doesn't get killed  
i sent a function with the parameters below  
msg.kill = "SIGHUP";  
return msg;  
it keeps running even though it shows an error

---

<div class="post-metadata">

### Author: ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)
#### Post date: [5 November 2020 07:21 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/10 "2020-11-05T07:21:01Z")

</div>

I am facing the same issue, Help me Out to return the msg.kill...

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 November 2020 07:42 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/11 "2020-11-05T07:42:55Z")

</div>

There have been some changes to the way exec works since this thread, please start a new thread with more details of what you are doing and what the problem is.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 November 2020 07:43 UTC](https://discourse.nodered.org/t/how-to-stop-an-exec-node-run-another-exec-node-and-when-its-finished-rerun-the-first/14416/12 "2020-11-05T07:43:04Z")

</div>


