Hi,
I can give this link
https://www.ibm.com/support/knowledgecenter/SSFTBX_8.5.5/com.ibm.wbpm.admin.doc/topics/using_perfsvr_commands_prune_run.html
Also I can give
https://www.ibm.com/support/knowledgecenter/SSNJFY_8.0.1/com.ibm.wbpm.admin.doc/adminguide/topic/removing_proc_instances_db.html
https://www.ibm.com/support/knowledgecenter/SSFPJS_8.5.7/com.ibm.wbpm.ref.doc/topics/rref_BPMProcessInstancesCleanup.html
you can automate these 2 things by using shell script and wsadmin which I have done.