on 01-23-2015 12:04 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.