Automated n8n Workflow Cleanup
detail.loadingPreview
This workflow automatically cleans up old n8n executions, freeing up resources and improving performance. It's triggered on a schedule or manually, ensuring your n8n instance stays lean and efficient.
About This Workflow
This n8n workflow is designed for efficient n8n instance management by automatically identifying and deleting older workflow executions. It leverages the n8n node to query for existing executions and an If node to apply a condition: only executions older than 10 days are targeted for deletion. This proactive approach prevents data bloat and potential performance degradation associated with accumulating execution logs. The workflow can be initiated either manually via a 'Test workflow' trigger or automatically on a daily schedule, ensuring consistent maintenance without manual intervention. By deleting outdated data, this workflow helps maintain optimal n8n performance and resource utilization.
Key Features
- Scheduled Cleanup: Automatically runs daily at 4:44 AM to maintain your n8n instance.
- Manual Trigger: Allows for on-demand execution and testing.
- Conditional Deletion: Only removes n8n executions older than 10 days, preserving recent data.
- Resource Management: Helps optimize n8n performance and storage.
- Flexible Operations: Supports both scheduled and manual cleanup operations.
How To Use
- Add a Trigger: Configure either the 'When clicking ‘Test workflow’' (manual) or 'Schedule Trigger' (daily at 4:44 AM) node to initiate the workflow.
- List Executions: Connect the trigger to the 'n8n list execution' node. Ensure the 'n8n account' credentials are set up correctly.
- Define Cleanup Condition: Connect 'n8n list execution' to the 'If' node. Configure the condition to check if the
startedAttimestamp of an execution isbeforethe date 10 days ago (using{{ new Date(Date.now() - 10 * 24 * 60 * 60 * 1000).toISOString(); }}). - Delete Old Executions: Connect the 'true' output of the 'If' node to the 'delete execution' node. Ensure the 'executionId' parameter is set to
={{ $json.id }}and the 'n8n account' credentials are correct. - Handle Unmatched Executions: Connect the 'false' output of the 'If' node to the 'No Operation, do nothing' node to ensure the workflow completes even when no executions meet the deletion criteria.
Apps Used
Workflow JSON
{
"id": "3ac26fce-f7fe-4c95-bd52-6ab8eeb6953a",
"name": "Automated n8n Workflow Cleanup",
"nodes": 27,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 3ac26fce-f7fe...
About the Author
AI_Workflow_Bot
LLM Specialist
Building complex chains with OpenAI, Claude, and LangChain.
Statistics
Related Workflows
Discover more workflows you might like
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.
Robust Concurrency Control for n8n Workflows with Redis
Prevent simultaneous execution of critical n8n workflows or tasks using a centralized, Redis-backed locking mechanism. This reusable utility workflow ensures data integrity and resource management by allowing other workflows to acquire, check, and release locks.
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.