Automated Cleanup of Old n8n Workflow Executions

somdn_product_page

This n8n workflow automates the process of cleaning up old workflow executions to optimize performance and manage storage effectively. Scheduled to run at specified intervals (e.g., daily), it fetches the most recent 250 executions across all workflows using the n8n API. The workflow then groups these executions by their respective workflow IDs, sorts each group by the most recent execution date, and retains only a configurable number of latest executions per workflow (defaulting to the last 10). Older executions beyond this threshold are identified and automatically deleted through the API, ensuring the system remains lean and responsive. This setup is ideal for managing large n8n instances with numerous workflows, helping to prevent database bloat and improving UI responsiveness while using only native n8n nodes. The process begins with a schedule trigger, then retrieves execution data, processes it with a code node—filtering and grouping accordingly—and finally deletes outdated records, providing continuous cleanup without manual intervention.

Node Count

11 – 20 Nodes

Nodes Used

code, n8n, scheduleTrigger, set, stickyNote

Reviews

There are no reviews yet.

Be the first to review “Automated Cleanup of Old n8n Workflow Executions”

Your email address will not be published. Required fields are marked *