// Deleting background tasks - deleting the related file entries as well import com.liferay.background.task.kernel.util.comparator.BackgroundTaskCreateDateComparator; import com.liferay.portal.kernel.backgroundtask.BackgroundTask; import com.liferay.portal.kernel.backgroundtask.BackgroundTaskManagerUtil; import com.liferay.portal.kernel.dao.orm.QueryUtil; import java.util.List; // Group Id of the Site long groupId = 0; // Portlet exports List portletBackgroundTasks = BackgroundTaskManagerUtil.getBackgroundTasks( groupId, "com.liferay.exportimport.internal.background.task.PortletExportBackgroundTaskExecutor", Boolean.TRUE, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new BackgroundTaskCreateDateComparator()); // Site exports List layoutBackgroundTasks = BackgroundTaskManagerUtil.getBackgroundTasks( groupId, "com.liferay.exportimport.internal.background.task.LayoutExportBackgroundTaskExecutor", Boolean.TRUE, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new BackgroundTaskCreateDateComparator()); List backgroundTasks = new ArrayList<>(); backgroundTasks.addAll(portletBackgroundTasks); backgroundTasks.addAll(layoutBackgroundTasks); for (BackgroundTask backgroundTask : backgroundTasks) { BackgroundTaskManagerUtil.deleteBackgroundTask(backgroundTask.getBackgroundTaskId()); }