New workflow to remove execution history of specific workflow peiordically

I’m new to N8N and exploring it for better use.

Problem:

We have three to four N8N workflows. Each workflow is a cron job and triggers at specific interval. All the workflows are creating many execution history. But we don’t want to delete the execution history of all the workflow.

There are couple of workflows which generates many execution history, we want to wait for specific time interval and remove the execution history of that particular workflow.

We don’t want to use the environment variable to perform this, as the environment variable purges across all workflows.

Is it possible to create another workflow that purges the execution history created by a specific workflow?. If so, please share a sample json to try.

N8N local setup:

  • n8n version: 0.166.0
  • Database you’re using: default: SQLite
  • Running n8n with the execution process: own(default), main

Hey @vibinchander, welcome to the community!

You wouldn’t need a workflow for this and could simply follow the implement the maintenance steps described here in the docs (and seeing you’re using SQLite also the part from the Keep in mind box) and then restart n8n.

The restart can take quite a while if you already have a lot of executions in your database (@mcnaveen tested this recently with 100,000s of executions, you can find a first hand report here).

This process will also require some free space on your hard drive (SQLite essentially rebuilds the database before deleting the old one).

1 Like

@MutedJam Thank you for the response. Appreciate it!.

As mentioned in my question earlier. We do not want to use the environment variable setup to enable the pruning process. Because it prune the data across all the workflows. We did not want that to happen.

For example we want a report of number of execution happened on other workflows in a week, but not the execution history of a specific workflow.

I see examples where this can be done when N8N is connected to DB at the backend. But not sure if this can be done with no db attached to N8N.

Hey @vibinchander, other approaches would be unsupported and I wouldn’t recommend them when using SQLite (as it doesn’t handle concurrent writes too well from the looks of it).

That said, there still is a database and you can access it through tools such as sqlite3. So maybe you could consider stopping n8n for the duration of your maintenance and then delete the data you no longer need using sqlite3? The data structure is described here:

You may want to look at the Settings for your workflow. For example, set the Save Data Succes Execution to Do not save …

1 Like

will have to go with this solution for time being. Agreed

Hi @MutedJam, I am using PostgreSQL 13.7 for storing the execution history. But I noticed if I publish any changes in one of the workflows it removes the execution history. Am I doing something wrong? Cheers