views:

211

answers:

2

Say I've got two scheduled processes: A and B.

Given that B should not run until A has completed, how might I gracefully enforce this dependency?

Approaches that have been considered:

  1. Have A schedule B upon completion. This has the downside of B never being scheduled if for some reason A failed.

  2. When B runs, have it ping A to see if the latter has completed. How this might be accomplished (network, file, database record, message queue) could be messy and problematic introducing a third dependency.

  3. Combine A and B into a single process. This has the downside of tightly binding the two, making it harder to re-run one or the other in isolation if need be.

Thoughts?

+2  A: 

Your option 1 directly answers your question: if B is dependent on A, and A fails, A not scheduling B means that B can't happen.

Unless B merely has to run after A does, whether or not A was successful.

In that case, something like the following (in bash) would work:

A && B
warren
+1  A: 

You could modify step 3: Create your two processes to run in isolation, and then create a third process that runs the other two.

Craig Walker