Managing Workflow Execution via Publish in n8n
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
}
}