Skip to Content

How can I prevent other jobs from running while running a scheduled job?

I have a job that reads data from SQL Server and stores the data in a local persistent cache on my DataServices JobServer.

This persistent cache in then used by other jobs that run on demand through out the day. These on demand job as started via the Run_Batch_Job webservice call.

I would like to be able to schedule the job that loads the persistent cache files to run at a set time every day. However, when this job is running I need any other jobs to wait until the persistent cache job is complete. Otherwise these job will access incomplete, or unreadable, cache files since they are trying to run at the same time that the cache is being reloaded.

How can I make these jobs aware that the persistent cache job is running, and how can I get them to wait until it is complete before they stop?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Dec 16, 2015 at 10:13 PM

    You can use a control table with a "running" flag.

    In a startup script of your primary job, that flag is set. It is cleared at the end of the job.

    All other jobs start with checking the flag. When it is set, they go into a loop: sleep, wake up and try again.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Dirk,

      Thanks for the quick response!

      I think your solution is great. I will modify it slightly and just create an empty file, with a specific file name at the start and then delete the file when the main job is complete.

      Then my other jobs will simply need to check if this file exists or not, and go into the loop if the file is found.

      Same basic principal, just using a simple file based system rather than a database query.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.