Skip to main content

Automatically prune n8n execution history

Workflow preview

Workflow preview
100%
Automatically prune n8n execution history preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Automated Execution Pruning 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...

Best for

  • DevOps automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.n8n, n8n-nodes-base.if, n8n-nodes-base.scheduletrigger, n8n-nodes-base.noop

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Danger.

Original n8n.io source

1.1 Workflow description

Title
Automatically prune n8n execution history
Workflow name
Automatically prune n8n execution history

Automated Execution Pruning

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.


Key Features:

  1. Configurable Retention Period:
    The workflow is preconfigured to delete workflow executions older than 10 days. You can easily adjust this duration by modifying the condition in the If node.

  2. Daily Automation:
    Using the Schedule Trigger, the workflow runs daily at the specified time (default: 4:44 AM), retrieving all workflow executions and identifying those that are older than the defined retention period.

  3. On-Demand Testing:
    The Manual Trigger allows you to test the workflow at any time, ensuring everything is working as expected.

  4. Decision Making:
    The If node evaluates each execution based on its start date and determines whether it should be deleted or retained.

  5. Execution Pruning:

    • Delete Action: Executions meeting the criteria are removed via the Delete Execution node.
    • No-Operation: Executions that don't meet the criteria remain untouched.

Workflow Nodes:

  1. Manual Trigger: Enables on-demand testing of the workflow.
  2. Schedule Trigger: Runs the workflow daily at the configured time.
  3. n8n List Execution: Fetches all executions in your n8n instance.
  4. If Node: Compares the execution's start date with the configured retention period.
  5. Delete Execution: Deletes executions older than the specified retention period.
  6. No Operation: Serves as a placeholder for executions that don't meet the pruning criteria.

How to Customize:

  • Retention Period:
    Update the If node's condition to modify the retention period. For instance, change 10 * 24 * 60 * 60 * 1000 to the desired number of days in milliseconds.

  • Schedule:
    Adjust the timing of the Schedule Trigger to match your preferred automation schedule.

This workflow ensures your instance remains efficient by keeping only the relevant execution logs. Use it to maintain a streamlined and clutter-free environment effortlessly.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - n8n1

Type / Role
n8n-nodes-base.n8n - n8n
Config choices
Version 1

Block 3 - n8n list execution

Type / Role
n8n-nodes-base.n8n - n8n
Config choices
Version 1

Block 4 - If

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 5 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 6 - delete execution

Type / Role
n8n-nodes-base.n8n - n8n
Config choices
Version 1

Block 7 - No Operation, do nothing

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

3. Summary Table

Workflow Automatically prune n8n execution history
Complexity intermediate
Nodes 7
Categories DevOps
Author Danger
Published 17 Dec 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2646/2646.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automatically prune n8n execution history do?

Automated Execution Pruning 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...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your DevOps use case.