What does node red use for its scheduling on timing intervals? Does it use cron or its own internal methodology? I have a flow that I would like to run as consistently as possible on multiple systems, such that it runs 12 times per hour, aligned to the top of the hour, then every 5 minutes there after. This is pretty easy to do via cron for various scripting efforts. But to get node red to mimic this behavior? Wondering if anyone has had a similar requirement? Of course the various systems always vary a bit, even if the system clocks are consistently aligned via NTP, chrony, etc. That is ok, just need to get this task as close to synchronized across sysems as good or as is reasonable. I suspect if I implement NTP, chrony, node red will just leverage the system clock like any other application would, for scheduling, right?
setInterval, and for the more complex ones it is using cron.
There is also a
node-red-contrib-cron-plus node available, if you prefer something that looks more obviously like cron formatting.
as per above - the inject node's 'interval between times' and 'at a specific time' option both use cron.
Just to clarify - yes the Inject node uses the
cron npm module under the covers. But that does not mean it uses the cron subsystem of the operating system - it just mimics the cron syntax. Deeper under the covers it still comes down to
Exactly what I was expecting, thinking, thanks. I wrote a simple flow that uses a delay node and sets msg.delay to force the actual message release to be clock (seconds) aligned. So for example, if I wan the interval to be 5 seconds, but the first inject is at 2 seconds on the clock, the delay is 3 seconds. I see messages passed in sync with the clock, .i.e. 0, 5, 10, 15, 20, 25, etc. of the current minute. I will check out the cron plus module, likely it will be simpler to use it.
Isn't 12 times per hour the same as every 5 minutes?
I believe that if you set an inject node to repeat at Interval between times every 5 minutes and set the time range 00:00 to 00:00 then it will be aligned to the hour. If I understand correctly then that should do exactly what you want.
The node-schedule library works very well too. I like the fact it’s easy to schedule events at a specific date and time.
I am using the cron-plus, it was very easy to migrate my python scripting scheduling to node red as I am replacing python for node red over time.
Yes, but the trick was I wanted the schedule to align to the top of the hour, so that all devices basically do the same thing at the same time, regardless of what node red stops or starts. Given the internal/timeout nature of the automated repetitive injections over time the various devices would tend to drift and lose the tight(er) synchronization I was after.
An inject node configured as stated does do that. Check the help text for the node.
That is a feature of
node-red-contrib-cron-plus node. As well as extended Cron expressions and solar times.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.