cancel
Showing results for 
Search instead for 
Did you mean: 

View Deletion for Process server and Agent

Former Member
0 Kudos

Hi ,

Can anyone tell , How can we delete view for jobs which ran on platform agent or process server .Please note , I am not asking log but view which is being created for every job run .

I want to delete job view in bulk .

Regards

Gurbakhshinder Singh

Accepted Solutions (0)

Answers (1)

Answers (1)

h_carpenter
Active Contributor
0 Kudos

Hi Gurbakhshinder Singh,

I do not understand what you want to delete. Do you want to delete jobs with output so they do not appear in "Monitoring > Jobs", remove the view privilege from some users so they do not see the jobs anymore, or do you want to delete job output and keep the log files ?

Regards,

HP

Former Member
0 Kudos

Hello HP,

Just mentioned below example : job definition has been removed which has log but like job chain and step is visible .

Such logs are existing for more than 200 different jobs(approx 50000) and I want to delete in bulk not selecting each job but in single shot.

Regards

Gurbakhshinder Singh

h_carpenter
Active Contributor
0 Kudos

Hi Gurbakhshinder Singh,

Ok, I assume it is something you want to do regularly. I would create a job definition that queries the datamodel for jobs that match your case and deletes them. I would schedule that to run weekly.

I doubt you want to delete jobs that ran yesterday or today, for example, so you also need to specify a date.

try something like

{

  //Get all job chain jobs which have reached a final status, added here so you can easily filter out

  String query = "select Job.* from Job where Job.JobChainCall is not null and Job.Status in ('K', 'U', 'A', 'E', 'C')";

  for (Iterator it = jcsSession.executeObjectQuery(query, null); it.hasNext();)

  {

    Job j = (Job) it.next();

    //we check again to make sure we have a final status, do not delete jobs that are not final.

    if(j != null && j.getStatus().getState() == JobStatusState.Final)

    {

      jcsOut.println("Deleting j "+ j.getDescription()+" ("+j.getJobId()+")"+", which has the status "+ j.getStatus()+".");

      //We want a dry run ... you want to make 100% sure you delete what you want - only uncomment when you are sure!

      //j.deleteObject();

    }

    jcsSession.persist();

  }

}

The trick here is that only job chain calls have JobChainCall set to a value. Note that you might have to adapt this if you have child job chains (job chains in job chains).

You could then add some date/time criterion to the query to delete jobs that are older than one week.

Use the Shell to write your code, only once you are 100% sure should you go ahead and uncomment the deleteObject() code - there will be no easy way back if you do not watch out; you have been warned. 😉

Regards,

HP

Former Member
0 Kudos

Thanks HP to give this idea and definition . Will test it .

h_carpenter
Active Contributor
0 Kudos

You could try the following query, it will select jobs that finished running at the least 7 days ago.

String query = "select Job.* from Job where Job.JobChainCall is not null and Job.Status in ('K', 'U', 'A', 'E', 'C') and Job.RunEnd < now(substract 7 days)";

Regards,

HP