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.
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
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.
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?
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.
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..