How to accurately trace the execution logs of scheduled jobs

mugi-san
Kilo Sage

Hello, Everyone.

 

I found the sys_scheduler_job_history table, but unfortunately, it doesn't seem to record the start time, end time, or success/failure status.

I believe that outputting messages to the system log and then searching through them to find what I need is not a very "smart" or efficient implementation.

Does anyone know if there is a standard table or feature that records the start time, end time, and execution status of scheduled jobs?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@mugi-san 

that's correct, you won't get exact start time, end time and any success/error details

you need to handle that using gs.info() statements and use try catch block to throw any exception

Something like this

(function() {

    try {
        gs.info("My Scheduled Job ABC started" + new GlideDateTime());

        // your code

        gs.info("My Scheduled Job ABC ended" + new GlideDateTime());
    } catch (ex) {
        gs.info("Exception in scheduled job ABC" + ex);
    }

})();

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Thanks, @Ankur Bawiskar . @Its_Azar .

As you mentioned, it seems that the only way to output the data within the default features is through logs.
I found a similar discussion, so I’ll include the link here as a reference to make it easier for others to find.

https://www.servicenow.com/community/developer-forum/where-to-find-job-log-for-a-scheduled-job-that-...


https://www.servicenow.com/community/itom-forum/how-to-check-the-log-of-a-scheduled-job/m-p/2720398

Regards.

Its_Azar
Kilo Sage

Hi there @Ankur Bawiskar 

 

I always log my custom apps using gs.infos. like ankur mentioned you can get these timings and  logs them using GS.info.

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.