Job Enabled and Schedule Enabled confusion

  • Hello,

    I can't seem to reconcile this and can't find a clear explanation on it.

    I have a Job set up with a Recurring schedule.

    When both Job and its Schedule are Enabled, the Job will run normally.

    When Job is Enabled but Schedule isn't, the Job will not run.

    When Job is Disabled but the Schedule is Enabled, the Job runs.

    I don't get how the Job can be Disabled yet still run when its Schedule is Enabled.

    What is the purpose then of Enabling a Job is the Schedule is what controls if it runs or not?

    Thanks!

  • phrankbooth (2/5/2009)


    Hello,

    I can't seem to reconcile this and can't find a clear explanation on it.

    I have a Job set up with a Recurring schedule.

    When both Job and its Schedule are Enabled, the Job will run normally.

    When Job is Enabled but Schedule isn't, the Job will not run.

    When Job is Disabled but the Schedule is Enabled, the Job runs.

    I don't get how the Job can be Disabled yet still run when its Schedule is Enabled.

    What is the purpose then of Enabling a Job is the Schedule is what controls if it runs or not?

    Thanks!

    ".. When Job is Disabled but the Schedule is Enabled, the Job runs.."

    Sounds wrong .... Are you sure about that ??

  • I'm absolutely sure about it. I ran a Trace on it.

  • I've never encountered that. It shows disabled in the GUI ? Does the "Last Run" get updated afterwards ?

    If you look at the "enabled" field in msdb..sysjobs, what do you see ?

  • GUI and DB settings are as expected.

    I have done manual runs atkleast 10 times and same results, Schedule must be Disabled to stop Job.

  • I'm having the same issue, job disabled, schedule enabled, job runs.

    (I'm running sql 2008 sp1)

    My jobs were created via a maintenance plan, were yours too?

  • Try restarting sql server agent service after disabling the job...seems to work for me.

  • Are you disabling the job via the GUI or code? If code, please show the code.

  • GUI

  • You can generate the code. Open the job, uncheck the "enabled" button, then "Script to new window"

    I can't replicate that in 2005. Tried a "regular" job and a maint plan job. Don't recall it ever happening either.

    You could query these tables for that specific job and see what the enabled values are:

    sysjobs

    sysjobschedules

    sysschedules

  • I just tried to reproduce the issue as well and couldn't do it.

    This DID occur on my production box this morning though.

  • The reason I was asking is i had a similar problem when I would failover our mirror databases. The code that was enabling/disabling the database specific jobs wasn't "working". Where the jobs were being disabled, they kept working and where the were being enabled they would run.

    I had to modify my code to use the sp_update_job stored procedure in the msdb database. Turns out that SQL Server Agent caches the information and this stored procedure forces a notification to SQL Server Agent.

  • Sounds like the lesson for the day is to use sp_update_job to enable / disable and to avoid the GUI

  • Not really. When I used the GUI to enable/disable the jobs, it cleared up the problem. I am pretty sure that the GUI uses the stored proc. You would need to run a trace to be sure.

  • Few months ago we decided not to have a schedule enabled in disabled jobs to avoid unwanted runs, like described above

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic. Login to reply