1

I have a Sql server 2012 agent job which currently runs every minute, every day, etc.

I'd like to modify it so that it will run every minute, every day except on Saturdays between 7:00 pm and 11:30 pm. Is this possible with the job scheduler?

I tried using a daily frequency and I can change the time on a per day basis that way, but not for a specific day.

Current schedule:

enter image description here

  • 7
    I've never tried this but I think I've seen that you can have multiple schedules on a single job. If so, create one for every minute on every day except Saturdays, and possibly two more for Saturdays, 12am till 7pm and 11:30pm till 12:59pm. – Andriy M Jul 16 '13 at 18:19
  • 2
    Or one schedule that runs every day from 11:30pm to 06:59pm and another that runs every day except Saturday from 07:00pm to 11:29pm – SQLFox Jul 16 '13 at 18:26
  • Would it be possible to run a .NET application whose sole job is scheduling rather than having a Sql Server job? #Quartz – jcolebrand Jul 16 '13 at 18:40
  • 1
    @jcolebrand Yuck. Sounds like far more trouble than it's worth. – Mansfield Jul 16 '13 at 18:41
  • I've used multiple schedules for a single job and they work, so @AndriyM's idea is pretty valid. You could give that a try. – Marian Jul 16 '13 at 19:51
7

I don't think you can work with that single job to get that exact schedule. You might want to consider having another job that disables/enables the job for the period of time that you don't want it to run. Another solution would be to add another conditional logic to your existing job and do a check on the current day of the week and what time it is, and decide whether or not to execute your job's logic.

A few alternatives here, but I think you'll have to get creative with your relatively complex schedule.

|improve this answer|||||
  • 1
    Interesting. Any thoughts on @AndriyM's comment? (would that be preferable to your idea for instance) – Mansfield Jul 16 '13 at 18:26
  • I second conditionals within the code – jcolebrand Jul 16 '13 at 18:40
  • 1
    Yep, that should definitely be a possibility. Whatever solution you choose, the point is it'll have more than one dimension that we typically work with. – Thomas Stringer Jul 16 '13 at 18:41
  • @jcolebrand Unfortunately this job calls an SSIS package, and the problem I'm trying to avoid is based on the SSIS package running at all, not what it's doing (the SSIS maintenance job is running into locks, more info here if you're interested: ssistalk.com/2012/07/16/…) – Mansfield Jul 16 '13 at 18:45
1

Avoid the hassle of creating another job which disables this job etc. To keep things simple:

End current schedule on Saturday 6:59:00 PM.
Create another schedule with same frequency starting on Saturday 11:00:00 PM.

Another way of seeing this question is:

How do I maintain the same frequency expect between x & y. 

This is a common situation and the need behind this is justified for any planned maintenance. I hope MS implements a more robust schedule.

|improve this answer|||||
0

You have to create 3 jobs as weekly, 1 set weekly for Sun-Fri 12am-11:59pm and another 2 to set weekly to run on saturday only, one for in the morning and one for after.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.