How do I make sure only one instance of my scheduled job is running at any given point of time?

prabhasgupte
Kilo Expert

I have a requirement: My scoped application have a scheduled job which executes a script include whenever it runs. I need to implement singleton for this scheduled job - meaning, only one instance of that job should be running at any point of time.

How can I achieve that with servicenow?

What I had on my mind is:

Job runs and checks some place to see if another instance of it (or of that script include) is already running.

If yes, terminate yourself. If not, go ahead and do the job.

7 REPLIES 7

I don't use Lock all that often, but it should do the trick in this case. It prevents other instances of the workflow from continuing past the lock until after the lock is released.



http://wiki.servicenow.com/index.php?title=Utility_Activities#Lock


Thanks Chuck.   We are trying to use this functionality with no luck.   The "other" lock never picks up after the first lock releases it.   I've opened a ticket with SN but I have a feeling I'm missing something vital in relation to these locks.


Keep me informed. I'm most interested in learning more.