on 08-25-2016 8:44 AM
Hi All,
I'm running CPS Build M33.120-83827
I have approximately 300 very old jobs in Job Monitor that are currently in Console status, which I need to delete.
Note: the corresponding Operator Messages were deleted as part of regular system maintenance a long time back.
Since these jobs aren't in a Final State, I'm aiming to change their status to Unknown and then proceed with deletion.
Note: I do not want to terminate these jobs as I don't trust how many new jobs it'll spawn as a result. Termination of these jobs will also result in automatic incidents being raised in my system which I would rather not happen.
Given the sheer number of jobs, manually forcing each job into Unknown status is a very cumbersome process.
Is anyone aware of a Redwood script (or any other method), to perform a mass job status change to Unknown? Possibly a script that takes in a mass list of JobIDs and iteratively modifies the status of each?
Appreciate any assistance.
Thanx.
-V-
Hi Vinit,
You could do the following:
{
//Execute a query to get all jobs in status Console (letter O) that started more than 1 day ago
for (Iterator it = jcsSession.executeObjectQuery("select Job.* from Job where Job.Status = 'O' and Job.RunStart < now('subtract 1 day') order by Job.JobId DESC", null); it.hasNext();)
{
//get the job
Job j = (Job) it.next();
jcsOut.println("Job :" + j.getDescription() + " ("+ j.getJobId() + " ) has status: " +j.getStatus() + " (" + j.getStatus().getCodeEx() + ")");
//create the job to force status to unknown
Job setUnknown = jcsSession.getJobDefinitionByName("System_ForceJobStatusUnknown").prepare();
setUnknown.getJobParameterByName("JobId").setInValue(j.getJobId());
//Uncomment the following line to make the whole thing wet
//jcsSession.persist();
}
}
Note that I have commented-out jcsSession.persist(); which actually saves the changes to the database and creates the jobs ... I do this so you can verify using the output in the shell that you are only affecting the jobs you mean to ... I order descending, so that the first are the "newest" ...
Regards,
HP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vinit ,
Use predefined System_ForceJobStatusUnknown to move the job status from console to Unknown.
If its 1 job you have to give job id to convert from console to unknown.
if its mass then you have to processserver name , but we cant filter with the job name to convert from console to Unknown.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You want to be very careful here as potentially you set all jobs in your system in Unknown here!!!
- The JobId parameter is a Number field and MUST take a BigDecimal as input.
- Also pass in the ProcessServer, just to be sure.
- Use a bind variable for the date selection as the 'now' sql option has some caching issues
{
//Execute a query to get all jobs in status Console (letter O) that started more than 1 day ago
DateTimeZone yesterday = DateTimeZone.expressionNow("subtract 1 day");
for (Iterator it = jcsSession.executeObjectQuery("select Job.* from Job where Job.Status = 'O' and Job.RunStart < ? order by Job.JobId DESC", new Object [] {new Long(yesterday.getUTCMilliSecs())}); it.hasNext();)
{
//get the job
Job j = (Job) it.next();
jcsOut.println("Job :" + j.getDescription() + " ("+ j.getJobId() + " ) has status: " +j.getStatus() + " (" + j.getStatus().getCodeEx() + ")");
//create the job to force status to unknown
Job setUnknown = jcsSession.getJobDefinitionByName("System_ForceJobStatusUnknown").prepare();
setUnknown.getJobParameterByName("JobId").setInValueNumber(new java.math.BigDecimal(j.getJobId().toString()));
setUnknown.getJobParameterByName("ProcessServer").setInValueString(j.getProcessServer().getName());
//Uncomment the following line to make the whole thing wet
//jcsSession.persist();
}
}
Regards Gerben
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.