How to schedule jobs to run one after another one, in sequence, one at the time?

juan_villalta
Kilo Contributor

I'm working with the "Service Portfolio Management", specifically with the Availability process. This one has a scheduled job - Calculate Availability - which runs every day at 2am, server time. Now, I need to run a process that will update additional availability records, right "after: the Calculate Availability job has finished. What I would like to have is just another scheduled job that waits for the first one to run. Any suggestion here? I've been browsing features of Aspen, the release we have installed, and can't find anything that helps me to set jobs in sequence, with dependency (not timely set). Thanks for your suggestions folks.

9 REPLIES 9

CapaJC
ServiceNow Employee
ServiceNow Employee

I'd just edit "Calculate Availability" and add your follow-on script right after whatever's there. Can't think of another way to keep the dependency.

That table is not "update synched", so changes to them aren't recorded as customizations. That means you won't have to worry about "owning" that scheduled job and not getting potential future updates, since scheduled jobs are never updated in an upgrade.


I was trying to stay away from adding updates to scripts that are part of plugins, precisely to avoid potential issues with SNC updates. But I guess I'll have to reconsider that alternative.

Here is question about this script then. Calculate Availability has this code:

var ac = new AvailabilitySummarizer();
var start = new GlideDateTime();
start.setValue(gs.beginningOfYesterday());
ac.summarize(start);

Does this mean that when the "summarize" method is called for execution, the Calculate Availability script waits until the summarize logic is completed in the server, and is until then that it can continue with code? If that is the case, then I'd just need to add logic like this one:

var ac = new AvailabilitySummarizer();
var start = new GlideDateTime();
start.setValue(gs.beginningOfYesterday());
ac.summarize(start);

var aj = new AdditionalJob(); ====> additional logic
aj.newProcess(); ====> additional logic

and this way the "newProcess" (method on class AdditionaJob, script include) will run AFTER the summarize script has finished in the server. Could anyone please confirm that this is the way this work? Thanks a lot.


Just to let you guys know, the test described above worked as expected. I put the job as script includes and then called it from the same scheduled job that run the other process. All worked fine.

However, when you have several processes that need to run at maintenance window, it would be nice to have a scheduler that allow you to define job dependencies, sequences, input/output conditions, all in order to keep the job sequences organized and individually executed.


juan_villalta
Kilo Contributor

.