on 05-23-2016 7:14 AM
Hi All,
I am trying to get the report of jobs of type 'CMD' which are currently in 'running' status for more than 20 min. Can anyone please help me with the select query.
Regards,
Chandu
select j.* from Job j, JobDefinition jd, JobDefinitionType jdt where j.JobDefinition = jd.UniqueId and jd.JobDefinitionType = jdt.UniqueId and jdt.Name = 'CMD' and j.Status = 'R' and j.RunStart < NOW('subtract 20 minutes')
Regards Gerben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Gerben for the query. I tried the query, but it is not listing any jobs which are currently active and running more than 20min. Please advise.
import java.util.Iterator;
import com.redwood.scheduler.api.model.Job;
import com.redwood.scheduler.api.model.SchedulerSession;
import com.redwood.scheduler.api.model.Table;
import com.redwood.scheduler.api.model.TableValue;
import com.redwood.scheduler.api.scripting.variables.ScriptSessionFactory;
import com.redwood.scheduler.api.date.DateTimeZone;
{
SchedulerSession session = ScriptSessionFactory.getSession();
String strSql= "select j.* from Job j, JobDefinition jd, JobDefinitionType jdt where j.JobDefinition = jd.UniqueId and jd.JobDefinitionType = jdt.UniqueId and jdt.Name = 'CMD' and j.Status = 'R' and j.RunStart < NOW('subtract 20 minutes')";
long lngDurationBefore=0;
Iterator it = jcsSession.executeObjectQuery(strSql, null);
while (it.hasNext())
{
Job j = (Job) it.next();
if (j.getJobDefinition().getName()!= null)
{
jcsOut.println(j.getJobDefinition().getName());
} else
{
// jcsOut.println(" No jobs match selected criteria ");
}
}
}
Regards,
Chandu
What have you tried so far?
thanks
Nanda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Nanda,
I tried below way as we have only 'CMD' jobs in this process server. I tried to first list all the jobs which are currently running and their duration. But the runtime in minutes(lngDurationBefore/60000) is returning a negative value. Not sure where I am doing wrong.
import java.util.Iterator;
import com.redwood.scheduler.api.model.Job;
import com.redwood.scheduler.api.model.SchedulerSession;
import com.redwood.scheduler.api.model.Table;
import com.redwood.scheduler.api.model.TableValue;
import com.redwood.scheduler.api.scripting.variables.ScriptSessionFactory;
import com.redwood.scheduler.api.date.DateTimeZone;
{
SchedulerSession session = ScriptSessionFactory.getSession();
DateTimeZone t = new DateTimeZone();
DateTimeZone t2 = new DateTimeZone();
t.setNow();
t2.setNow();
t2.truncateDay();
long currtime = t.getUTCMilliSecs() - t2.getUTCMilliSecs();
String strSql= "select j.* from Job j, ProcessServer ps where ps.SearchName = 'XX_PROCESSSERVER' and j.ProcessServer = ps.UniqueId and j.Status in ('R')";
long lngDurationBefore=0;
Iterator it = jcsSession.executeObjectQuery(strSql, null);
while (it.hasNext())
{
Job j = (Job) it.next();
if (j.getRunStart() != null)
{
lngDurationBefore=currtime - j.getRunStart().getUTCMilliSecs();
jcsOut.println(j.getJobDefinition().getName() + " " + lngDurationBefore/60000);
} else
{
// jcsOut.println(" No jobs in the specified criteria ");
}
}
}
Regards,
Chandu
User | Count |
---|---|
81 | |
25 | |
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.