cancel
Showing results for 
Search instead for 
Did you mean: 

Post Running Action

Former Member
0 Kudos

I have the below piece of code in the post running action and does what it is supposed to do and display the required information on the web page i have developed for the business. What i want to have is the run time (Elapsed time) for each job on the list I have. How do I calculate the difference in RUNEND and RUNSTART? Please help

     tv = webtable.getTableValueBySearchKeySearchColumnName("<Job Name>","RUNSTART");

     tv.setColumnValue(j.getRunStart().toFormattedString("dd-MMM-yyyy HH:mm:ss"));

     tv = webtable.getTableValueBySearchKeySearchColumnName("<Job Name>","RUNEND");

     tv.setColumnValue(j.getRunEnd().toFormattedString("dd-MMM-yyyy HH:mm:ss"));

     tv = webtable.getTableValueBySearchKeySearchColumnName("<Job Name>","STATUS");

     tv.setColumnValue(j.getStatus().name().toUpperCase());

Thank You

Accepted Solutions (1)

Accepted Solutions (1)

gmblom
Active Contributor
0 Kudos

DateTimeZone.formatDuration(j.getRunEnd().getUTCMilliSecs() - j.getRunStart().getUTCMilliSecs())

Regards Gerben

Former Member
0 Kudos

Blom

Thank you for your response. Have another question. Is there a table which stores the Run time(Elapsed Time) in cronacle? If so can you guide me with table name and object name how it is stored?

Thank you

gmblom
Active Contributor
0 Kudos

Hello,

All timing information is stored in the Job table. The elapsed time is not stored in a separate field.

Regards Gerben

Former Member
0 Kudos

Thank you Gerben your answers were so helpful and it worked for me as expected. But using the below line, is there a way also to format the string so it wont display the Millisecs?


DateTimeZone.formatDuration(j.getRunEnd().getUTCMilliSecs() - j.getRunStart().getUTCMilliSecs())

gmblom
Active Contributor
0 Kudos

Hello,

yes you can provide the format to the formatDuration call:

DateTimeZone.formatDurationEx(j.getRunEnd().getUTCMilliSecs() - j.getRunStart().getUTCMilliSecs(), '|1 week, |# weeks, |1 day, |# days, |#|:#|:#||')


I have left out the milliseconds now.


Regards Gerben

Former Member
0 Kudos

When i try to add this i get the below error at compile time. Am I doing any mistake?

method formatDurationEx(long) location: class com.redwood.scheduler.api.date.DateTimeZone tv.setColumnValue((DateTimeZone.formatDurationEx(j.getRunEnd().getUTCMilliSecs() - j.getRunStart().getUTCMilliSecs())));



This is how my line looks like currently without formatting the milli seconds.


tv.setColumnValue((DateTimeZone.formatDuration(j.getRunEnd().getUTCMilliSecs() - j.getRunStart().getUTCMilliSecs())));

gmblom
Active Contributor
0 Kudos

Hi,

Sorry, I was mixing REL and RedwoodScript:

tv.setColumnValue((DateTimeZone.formatDuration(j.getRunEnd().getUTCMilliSecs() - j.getRunStart().getUTCMilliSecs(), "|1 week, |# weeks, |1 day, |# days, |#|:#|:#||")));


Regards Gerben

Former Member
0 Kudos

Thank you so much Gerben.

Are their any documentation available with you that you can share on Pre, Post and on-change Actions? which explains with some examples on how to use these actions

gmblom
Active Contributor
0 Kudos

Hello,

In the documentation also examples are available. Look for triggering custom code.

Regards Gerben

Former Member
0 Kudos

Gerben

I ran into another problem while working on this set up.

I have the below piece of line where it fetches the job names.

for (Iterator jt = jcsSession.executeObjectQuery("select Job.* from Job where Job.JobDefinition in (select JobDefinition.UniqueId from JobDefinition where JobDefinition.Name in (<Job Names>)

While calculating the Elapsed time for a job chain, the code is doing it only for the last step of the chain but not giving me the Elapsed time for entire chain.

Can you please guide me with this.

Thank you

gmblom
Active Contributor
0 Kudos

Hello,

I hope you are not doing this in the post-running action right? But in a report script or so?

In the post-running action you can always find your own job with jcsJob.

So for the report, you want to limit your searches to not include steps (as they have the same definition name): select Job.* from Job where Job.JobChainStep is null and Job.JobDefinition in (select JobDefinition.UniqueId from JobDefinition where JobDefinition.Name in (<Job Names>)

Regards Gerben

Former Member
0 Kudos

Gerben

Thank you so much for you previous reply. I was able to get the elapsed time of the chain as opposed to only one step.

I also wanted to know if there is any possibility that the web page i have created to make it show a job which is in event wait or running state by using the pre-run or On-change actions? or any other way?

The current set up has post run action defined which updates the table upon job's completion and the same will be transferred over to the web page. I wanted to know if this can be done for event wait and job that is running.

Thank you.

Former Member
0 Kudos

Hi Gerben

Another problem i faced last night. I have a job "abc" which resides in chain "xyz". While i am calculating the run time i want the runtime to be updated in table for job "abc" and a separate row of runtime to be also updated for the chain "xyz"

Due to this select Job.* from Job where Job.JobChainStep is null and Job.JobDefinition where the job chain step is null, i am guessing i am not able to do this.

Can you please advise what should i do to get this done

Thank you

Answers (0)