# How to start a periodical task from an external command?

**URL:** <https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676>\
**Category:** General\
**Created:** [2 October 2020 15:56 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676 "2020-10-02T15:56:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![foobrizio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/foobrizio/32/28261_2.png) [@foobrizio](https://discourse.nodered.org/u/foobrizio)\
**Post date:** [2 October 2020 15:56 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676/1 "2020-10-02T15:56:14Z")

</div>

Hi everyone,  
as the title of this topic says, I want to start a periodical task on Node-RED, triggering it from an external command.  
I made an Android app and I'm gonna send an MQTT signal from it. When my flow receives this signal, it has to start a task that repeats every 15 minutes. How can I do it?  
I obviously can't use the inject node. I tried to use the trigger node, but I managed to repeat the task only twice with it.

---

<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:** [2 October 2020 16:03 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676/2 "2020-10-02T16:03:06Z")

</div>

the cron-plus node is fully automatable.

- add a cron expression that runs every 15m
- send a topic of "stop" to it to stop it
- send a topic of "start" to it to start it

See the built in help on the side bar for more details & see the built in examples (menu, import, examples, cron-plus)

---

<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:** [2 October 2020 16:15 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676/3 "2020-10-02T16:15:56Z")

</div>

how do you have the trigger node configured ? It should be possible no problem.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b74a4dc0ca7489b9e5a02020bb426cebb4ffc43.png)  
send any payload to start it, and send msg.reset to stop it.

---

<div class="post-metadata">

**Author:** ![foobrizio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/foobrizio/32/28261_2.png) [@foobrizio](https://discourse.nodered.org/u/foobrizio)\
**Post date:** [2 October 2020 16:27 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676/4 "2020-10-02T16:27:40Z")

</div>

Yeah, it should be......I configured it exactly as in your photo, but it doesn't work. I don't know why. I'm testing the cron-plus solution at the moment

---

<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:** [2 October 2020 16:44 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676/5 "2020-10-02T16:44:02Z")

</div>

what about it doesn't work ? It doesn't start ? it doesn't repeat ? It doesn't stop ?  
a simple test case is working here...

```auto
[{"id":"4c8ef058.e86e9","type":"inject","z":"e9b4dddd.70115","name":"start","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":120,"wires":[["a712caf3.34ac68"]]},{"id":"a712caf3.34ac68","type":"trigger","z":"e9b4dddd.70115","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-1","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":330,"y":140,"wires":[["a8cde462.c09df8"]]},{"id":"13e26bd4.352884","type":"inject","z":"e9b4dddd.70115","name":"reset","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":180,"wires":[["a712caf3.34ac68"]]},{"id":"a8cde462.c09df8","type":"debug","z":"e9b4dddd.70115","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":540,"y":140,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![foobrizio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/foobrizio/32/28261_2.png) [@foobrizio](https://discourse.nodered.org/u/foobrizio)\
**Post date:** [2 October 2020 18:04 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676/6 "2020-10-02T18:04:22Z")

</div>

As I said in the topic description, I managed to repeat the flow only twice, using trigger node.  
I'll try this flow, maybe I set up something wrong. Anyway the cron-plus node is what I was looking for. The possibility to start, pause, resume and remove the schedules is awesome and very helpful for me.

---

<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:** [16 October 2020 18:04 UTC](https://discourse.nodered.org/t/how-to-start-a-periodical-task-from-an-external-command/33676/7 "2020-10-16T18:04:26Z")

</div>

Closed on 16 October 2020 18:04 UTC

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