Any Possible way to Turn ON and OFF workflow based on schedule time

Is there any possible way to automatically turn on and off the workflow based on the schedule timing on the scheduled day?

Hi @mcnaveen, the Cron node can help you with that. You can find more information about the Cron node here: https://docs.n8n.io/nodes/n8n-nodes-base.cron/

1 Like

Unfortunately, cron job won’t turn on workflow, right?

Here is my use case.

I have a Cron job that does something every 5 Minutes.
But if i’m offline how can I auto turn on and off the workflow using Cron on specific day at specific time?

I want to control turn on and off the workflow.

Selection_262

Hi @mcnaveen, not sure what exactly you mean by turn on the workflow. With your current settings, the Cron node will trigger your workflow every five minutes (provided that it’s correctly connected).

Not sure what you mean by offline. The workflow will get triggered according to the settings of the Cron node as long as n8n itself is running. It doesn’t matter if the Editor UI is open on a browser window as long as the n8n process (for example, the docker container) is running. Hope that helps!

Let’s say, I have a workflow that sends updates every 5 Minutes using cron node.

But I have to make the Workflow Active for that, with the Button in top right corner. If the workflow is inactive, It won’t send right.

Suppose, If I’m offline (Away from the Internet). Can I make the Workflow ACTIVE at the scheduled time using a cron node?

Or make the workflow inactive at scheduled time.

Hope you’re getting my point

Hi @mcnaveen, that’s correct. The workflow will have to be set as Active for the Cron node to work. If you set a workflow as active, it will only run during the time specified in the Cron node (which could be either every five minutes or during the specified time).

Consider the example below, where I have set the Cron node to run the workflow at 12.45 everday. Even though the workflow is set to active, if we look at the executions, it executes only at the time set by the Cron node. You can add multiple conditions in the Cron node such as every minute or every X additionally.

Demo-Cron

So you’ll only have to set the Cron node correctly and set the workflow to active. If the workflow is not set to active, the only way to execute it, is manually.

1 Like

Another example could be where you probably want to execute the workflow every five minutes between 8-18 (the workflow would do nothing outside of this timeframe). In such cases, you can use the ‘Custom’ option from the Mode dropdown list and set the following for the Cron Expression field: 0 */5 8-18 * * *.

I use this website to generate custom Cron expressions: https://www.freeformatter.com/cron-expression-generator-quartz.html

Hope this helps! :slight_smile:

1 Like

Thanks for your reply @tanay

So the workflow active and deactivate can’t be scheduled now. Am I right?

How about execute workflow has an option to make the workflow active. Or inactive. It’d be awesome.