How to use LogCleanupCommand with jBPM

This article will teach you how to perform regular maintenance of the jBPM Database using the LogCleanupCommand, which removes historical data from your schema.

jBPM Historical Data

jBPM stores data about processes in a database to ensure

Some of your data will be removed as soon as the processes complete. For example, the ProcessInstanceInfo table only contains data about ACTIVE processes. However, there are some tables that keep historical data about Processes and Tasks. Here is the list of these tables:

  • Variableinstancelog
  • Taskvariableimpl
  • Taskevent
  • Processinstancelog
  • Nodeinstancelog
  • Bamtasksummary
  • Audittaskimpl

To avoid your Database to grow indefinitely, you have to run, at regular intervals, the LogCleanUpCommand which allows deleting records from the above tables, when they meet some configuration parameters

There are mainly two options to run the LogCleanUpCommand: you can either configure it to run automatically from the Business Central. Otherwise, you can invoke it through the REST API

Automatic scheduling of LogCleanUpCommand

Firstly, log in the Business Central and go to Manage and select “Jobs”.

LogCleanUpCommand tutorial

Click New Job.

Enter a name, due date, time, and the following command into the Type text field.

LogCleanUpCommand spring boot

Click Add Parameter if you want to use the parameters, enter a parameter in the key section and enter a parameter value in the value section.

Finally, click Create to finalize the job creation wizard.

Manual Scheduling of the Cleanup Job

In order to invoke manually the LogCleanUpCommand, we will use the REST API. The REST API exposes the /rest/server/jobs Endpoint as gateway to start a new Job. To keep it tidy, we will pass the Job Data as a file parameter.

Here is a sample execution with the curl command:

curl --location --request POST 'http://localhost:8090/rest/server/jobs' --header 'Content-Type: application/json' -d @clean.json

Within the clean.json, file we will declare the Job Command, the Scheduled Date and a set of Parameters to filter the execution. For example:

     "job-command" : "org.jbpm.executor.commands.LogCleanupCommand",
     "scheduled-date" : {
         "java.util.Date" : 1598569297234
     "request-data" : {
        "OlderThan" : "2022-10-08",
        "SingleRun" : "true"

Here is a list of accepted parameters:

  • SkipProcessLog – if true, omits the clean up of Process Logs
  • SkipTaskLog – if true, omits the clean up of Task Logs
  • SkipExecutorLog – if true, omits the clean up of Executor Logs
  • DateFormat – date format for further date related params. (default is yyyy-MM-dd )
  • EmfName – name of entity manager factory you will use for queries (valid persistence unit name)
  • SingleRun – indicates if execution should be single run only (true|false)
  • NextRun – provides next execution time (valid time expression e.g. 1d, 5h, etc)
  • OlderThan – deletes logs which are older than a date
  • OlderThanPeriod – deletes logs older than given time expression (valid time expression e.g. 1d, 5h, etc)
  • ForProcess – deletes logs only for given process definition
  • ForDeployment – deletes logs only for a deployment id
  • RecordsPerTransaction – indicates number of records to be included in each DB transaction (default is 0 which means do the delete in one single transaction)

Then, when you execute the Job, you should see the outcome on the KieServer Console:

2022-10-08 12:30:28.424  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : ErrorInfoLogsRemoved 4
2022-10-08 12:30:28.431  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : RequestInfoLogsRemoved 5
2022-10-08 12:30:28.442  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : TaskAuditLogRemoved 1
2022-10-08 12:30:28.448  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : TaskEventLogRemoved 2
2022-10-08 12:30:28.456  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : TaskVariableLogRemoved 1
2022-10-08 12:30:28.463  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : NodeInstanceLogRemoved 7
2022-10-08 12:30:28.470  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : VariableInstanceLogRemoved 2
2022-10-08 12:30:28.474  INFO 8170 --- [pool-8-thread-1] o.j.executor.commands.LogCleanupCommand  : ProcessInstanceLogRemoved 0

Launching the LogCleanUpCommand in Spring Boot applications

If you are starting jBPM embedded in a Spring Boot runtime, in order to fire the LogCleanUpCommand you have to include the following property in your Spring Boot configuration:


To learn more about jBPM REST API on Spring Boot, check this article: How to run jBPM REST API in Spring Boot


This article was a quick tour of the LogCleanUpCommand Job that you can use to delete historical data in your jBPM Database

Found the article helpful? if so please follow us on Socials