# Exec node unable to launch service

**URL:** <https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246>\
**Category:** General\
**Created:** [26 March 2021 21:37 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246 "2021-03-26T21:37:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cocothedoges](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cocothedoges/32/39246_2.png) [@cocothedoges](https://discourse.nodered.org/u/cocothedoges)\
**Post date:** [26 March 2021 21:37 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246/1 "2021-03-26T21:37:10Z")

</div>

Hi guys, from [previous](https://discourse.nodered.org/t/exec-node-creating-two-processes/43155) issues, im trying to run a ffmpeg command as a service...  
If I execute from command line, it works like a charm:

> pi@pi2:~ $ systemctl --user start myscript

But, when I execute it from exec node I got:

```auto
Failed to connect to bus: No existe el fichero o el directorio

```

the flow:

```auto
[{"id":"9e05b5cf.bce038","type":"exec","z":"bcea7856.3d9df8","command":"systemctl --user start myservice","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"ffmpeg","x":420,"y":120,"wires":[["ce60718c.630bf"],["ce60718c.630bf"],["ce60718c.630bf"]]},{"id":"72214724.8e5f18","type":"inject","z":"bcea7856.3d9df8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":120,"wires":[["9e05b5cf.bce038"]]},{"id":"ce60718c.630bf","type":"debug","z":"bcea7856.3d9df8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":120,"wires":[]}]

```

I've read across lots of linux forums and its seems its a issue related to enviroments variables like _XDG\_RUNTIME\_DIR_ or something.

Would somebody give me any clue about the issue and how to solve it? thx 😉

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 March 2021 22:17 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246/2 "2021-03-26T22:17:43Z")

</div>

When you are at the command line, run the command `set`. This will show you all of the environment variables you get from a standard command prompt. Now run the same command from an exec node and compare the two outputs.

In fact, I assign `process.env` to a global variable in my settings.js so that I have them all to hand when working with Node-RED (though note that you shouldn't do this if running in a shared environment as there can be quite sensitive things kept as environment variables). However, also note that the result of a `set` in an exec node might not be quite the same.

Now you can add the variables you need to the exec command you are running.

---

<div class="post-metadata">

**Author:** ![cocothedoges](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cocothedoges/32/39246_2.png) [@cocothedoges](https://discourse.nodered.org/u/cocothedoges)\
**Post date:** [28 March 2021 10:12 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246/3 "2021-03-28T10:12:12Z")

</div>

Now I hadded ${XDG\_RUNTIME\_DIR} environment variable. And the error has changed to:

> Failed to start myservice.service: Unit myservice.service not found.

Maybe other variables are needed, but I doesnt know witch of them.

---

<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:** [28 March 2021 10:26 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246/4 "2021-03-28T10:26:50Z")

</div>

Does it say exactly that or have you changed the actual name?  
Where have you put the service file?

---

<div class="post-metadata">

**Author:** ![cocothedoges](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cocothedoges/32/39246_2.png) [@cocothedoges](https://discourse.nodered.org/u/cocothedoges)\
**Post date:** [28 March 2021 10:34 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246/5 "2021-03-28T10:34:05Z")

</div>

Hi @Colin,  
Says exactly this, the script is located here (added 777 permissions temporally):

> /home/pi/.config/systemd/user/myscript.service

When I run it from command line it works, these make me assume that the service is properly configured.

---

<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:** [28 March 2021 10:41 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246/6 "2021-03-28T10:41:53Z")

</div>

You have got the name wrong. You are trying to start myservice, but it is called myscript.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 April 2021 10:42 UTC](https://discourse.nodered.org/t/exec-node-unable-to-launch-service/43246/7 "2021-04-11T10:42:03Z")

</div>

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