Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Managing Workflow Execution via Publish in n8n

Tech May 12 2

In recent iterations of the n8n platform, users may notice the absence of the "Active" button that was previously present in the workflow header. This UI element has been removed in favor of a publishing model. Concerns regarding the execution of scheduled tasks are unwarranted, as the functionality has been preserved through the "Publish" control.

To activate a workflow containing a schedule trigger, navigate to the top-right corner of the editor and select "Publish." The button state will update to "Published," accompanied by a green status indicator, signifying that the workflow is live. Background processes, including cron jobs and intervals, will execute automatically based on the defined trigger settings, independent of the user interface being open.

To cease execution, the workflow must be accessed via the editor, where the "Unpublish" option will revert the workflow to a static, inactive draft state.

The example below demonstrates a workflow that generates a time-stamped text file on the disk every ten seconds. This verifies that the trigger functions correctly after publishing.

{
  "name": "Periodic File Creation",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "seconds",
              "secondsInterval": 10
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [200, 300],
      "id": "trigger-01",
      "name": "Timer Trigger"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "assign-01",
              "name": "fileData",
              "value": "={{ $now.toFormat('yyyyMMddHHmmss') }}",
              "type": "string"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [420, 300],
      "id": "set-01",
      "name": "Set Payload"
    },
    {
      "parameters": {
        "operation": "toText",
        "sourceProperty": "fileData"
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [640, 300],
      "id": "convert-01",
      "name": "Make File Object"
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "={{ `/tmp/n8n-demo/${$now.toFormat('yyyyMMddHHmmss')}.txt` }}"
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1.1,
      "position": [860, 300],
      "id": "write-01",
      "name": "Save to Disk"
    }
  ],
  "connections": {
    "Timer Trigger": {
      "main": [[{"node": "Set Payload", "type": "main", "index": 0}]]
    },
    "Set Payload": {
      "main": [[{"node": "Make File Object", "type": "main", "index": 0}]]
    },
    "Make File Object": {
      "main": [[{"node": "Save to Disk", "type": "main", "index": 0}]]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "id": "demo-workflow-v2",
  "meta": {
    "templateCredsSetupCompleted": true
  }
}
Tags: n8n

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.