Data Processing

I have a scenario where i have a scheduled process runs every 5mins which runs and fetches the data from a system.

if next schedule runs before completing the previous run, my process should skip it.

Example:

schedule1 - ran at 10:00AM
schedule2 - ran at 10:05AM - By this time previous run(schedule1) was not completed, so i need to skip this process
schedule3 - ran at 10:10AM - By this time previous run(schedule1) was completed, so we can continue with process.

How can we achieve this in n8n

I don’t think there is such a built in feature right now. There is a global setting for concurrency that affects all workflows which is not ideal.

I would recommend something like this:

At workflow start:
Read a flag from a database / Redis / key–value store
If “running” → exit
If “free” → set “running=true” and continue

At workflow end:
Reset flag → “running=false”

This would be per workflow and you can add multiple workflow flags to the DB so you can easily reuse that later on for other tasks :slight_smile:

Hi @krisn0x Thanks for taking time and responding. I don’t have option to use external sources.

Forgot to mention this could be a Google Sheet or a local file as well, using the Read/Write files node. Is this off the table too?

Hello @prasad

If you don’t want to use a database or any external storage for the status, as krisn0x explained, you can use the n8n API to fetch workflow executions with Get many executions and check the "status" field.


You should consider redesigning your workflow based on this approach.


Additionally, I think you can make use of workflow static data to achieve what you’re looking for as well:

1 Like

Here is an idea:

When the workflow starts - deactivate the workflow, at the very end - activate is back:

The schedule runs every 10 seconds.
The Wait node wait for 15, which makes every second execution skip.

Runs like this:

  • Execution 1 starts at 15:05
    • Execution deactivates the trigger
    • Wait makes the execution wait until 15:20
  • Execution 2 which would have happened at 15:15 never runs
  • Execution 3 starts at 15:25
  • … story repeats.
1 Like

meta flow, I like it

Hi @mohamed3nan Thanks for taking your time and sharing the details.

I have tried the option of Get Many Executions with limit 1, considering that API is returning the latest data.

Testing:

  • I have executed the flow manually and in the flow kept the wait for 3mins.
  • While this flow is in-progress, I have send the request to n8n api directly, I was expecting the current execution will come in response but unfortunately it sharing me the already completed flow.

And i have observed that i am not seeing the status field in the response

Hi @jabbson Thanks for checking on this. looks this would work, I have a doubt here. Incase of any failures and the current execution has not reached to activate workflow step, then flow will be deactivated permanently correct?

You could add an error workflow and re-activate the flow there in case of failure.

1 Like

Hi @mohamed3nan I have spoken to n8n support, the current n8n API will not able to show the in-progress execution status, this feature in beta.. planning to release in next couple of weeks.

1 Like

That’s right, I actually haven’t implemented the full logic in the example I mentioned..
But if you query with the execution id while the workflow is running, you’ll get status: running.
And it’s great news that the in-progress execution status feature will be released soon..

1 Like

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