AutomationFlowsGeneral › Automatically Prune N8n Execution History

Automatically Prune N8n Execution History

ByDanger @dangerblack on n8n.io

This workflow is designed to help you manage and optimize your n8n instance by automatically pruning old workflow executions, ensuring a cleaner environment and improved performance. You can customize the retention period to suit your needs. Configurable Retention Period: The…

Event trigger★★☆☆☆ complexity7 nodesn8n
General Trigger: Event Nodes: 7 Complexity: ★★☆☆☆ Added:

This workflow corresponds to n8n.io template #2646 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "648130c4-5195-4b91-995b-443624019cd0",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        820,
        280
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c25e5656-9ce2-4429-98f5-f86a88a8fe16",
      "name": "n8n1",
      "type": "n8n-nodes-base.n8n",
      "position": [
        2380,
        140
      ],
      "parameters": {
        "filters": {},
        "options": {},
        "resource": "execution",
        "returnAll": true,
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "93acd82f-22ce-435c-b89e-a3f8ae876bc5",
      "name": "n8n list execution",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1040,
        380
      ],
      "parameters": {
        "filters": {},
        "options": {},
        "resource": "execution",
        "returnAll": true,
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "da03ff80-480d-4616-8aed-dd955d5e92d8",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1260,
        380
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6a124591-3347-4224-a997-a7824de12c96",
              "operator": {
                "type": "dateTime",
                "operation": "before"
              },
              "leftValue": "={{ $json.startedAt }}",
              "rightValue": "={{ new Date(Date.now() - 10 * 24 * 60 * 60 * 1000).toISOString();  }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6bc96f0a-5ed9-43f9-91e8-ced15ae53ef5",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        820,
        500
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 4,
              "triggerAtMinute": 44
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "272f94d2-fcb5-4e6a-a32e-655ac1db9a00",
      "name": "delete execution",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1480,
        280
      ],
      "parameters": {
        "resource": "execution",
        "operation": "delete",
        "executionId": "={{ $json.id }}",
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b2067d59-3678-400a-a464-cb7aab62413f",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1480,
        480
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "delete execution",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "n8n list execution",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n list execution": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "n8n list execution",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow is designed to help you manage and optimize your n8n instance by automatically pruning old workflow executions, ensuring a cleaner environment and improved performance. You can customize the retention period to suit your needs. Configurable Retention Period: The…

Source: https://n8n.io/workflows/2646/ — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Manual N8N. Uses n8n, manualTrigger, stickyNote. Event-driven trigger; 5 nodes.

n8n
General

Using n8n a lot?

Execute Workflow Trigger, XML, Move Binary Data +1
General

This workflow automatically handles errors in your n8n workflows by: Detecting when an error occurs and capturing the error details Sending an email notification with the error message and affected no

Error Trigger, Email Send, n8n
General

&gt; v2: Now it can read multiple types of LLM usages. Better dynamic approach for reading model usage.

n8n, Execute Workflow Trigger, Stop And Error
General

Self-Hosted n8n Workflow Backup to Google Drive. Uses googleDrive, n8n. Event-driven trigger; 17 nodes.

Google Drive, n8n