Start SQL job with condition

Hi, guys!

Our backup job is set to start every day at midnight. Can you tell me how to insert a step to this job to verify if others jobs are running and based on this:

  • if other job is running, postpone backup job.
  • if no job is running, start backup job.

Sure, I can put into one job more steps but I want to have them separately.

Thanks!

Why would you want to postpone the backup job if other jobs are running? Do you not run the risk that you do not have a "current" backup?

Kristen, I want to postpone if other jobs are running at that moment.

For example, if DBCC CHECKDB job is running and for somehow reasons is not finished until midnight, I would like to postpone backup job...let's say...for a half hour.

Of course, any other maintenance jobs were scheduled to run much earlier before backup starts but I would like this just in case.

Why not just run the backup anyway, whilst CHECKDB is running?

personally I don't see that as a reason to postpone a backup, but I'm happy to learn that there is a reason :slightly_smiling:

:))
I don't mind to have them running same time if this happens. I was thinking not to affect somehow the normal course of events (if I can put it like this).

They will be happy running at the same time. I think if you get "too clever" with scheduling you run the risk that, as other jobs are added over time, that your Backup runs as Second Priority, and then maybe does not run at a predictable time (and then interferes with user activity, meaning that you cannot get a Restore from a backup made at a "good time" during the day), or does not run often enough / fails to run.

I take the view that backup should be First Priority so that there is no chance that "something else" means that on the day when you have a disaster you then find that you don't have good backups to restore from :frowning:

Good arguments, Kristen!

I will drop this idea and focus on some other things.

Thank you.