Based on your description, you want the next job to run if at least one of the two database check jobs (DB-CHECK1 and DB-CHECK2) is successful. However, you want the next job to be suppressed if both DB check jobs fail. This requires a conditional dependency with an "OR" condition.
Here's how you could implement this logic:
- Use a wrapper script: Create a script that will control whether the next job should run. This script should check the exit status or result of DB-CHECK1 and DB-CHECK2. If either job is successful, the script will return success and allow the next job to proceed. If both jobs fail, the script will return failure, which will prevent the next job from running.
- Set the next job to depend on the script: Instead of directly linking the next job to DB-CHECK1 and DB-CHECK2, make it depend on the wrapper script you just created. This way, the script will act as a decision-maker to decide if the next job should run.
- Write the wrapper script: The script should check the status of DB-CHECK1 and DB-CHECK2 (possibly via exit codes or log files). If one of them is successful (has a successful exit code or the expected output in the logs), the script should exit with a success code (e.g., exit 0). If both fail, it should exit with a failure code (e.g., exit 1).
Here's an example of how your wrapper script should look:
#!/bin/bash
# Check the status of DB-CHECK1
check1_status=$?
# Check the status of DB-CHECK2
check2_status=$?
# If either check is successful (exit code 0), return success (exit code 0)
if [ $check1_status -eq 0 ] || [ $check2_status -eq 0 ]; then
exit 0
else
# If both checks failed, return failure (exit code 1)
exit 1
fi
- Schedule the script as the dependency: Instead of scheduling the next job to depend directly on the DB-CHECK jobs, make it depend on the wrapper script. The script's success or failure will dictate whether the next job runs.
Using this approach should help you achieve the desired control over your jobs and their dependencies.
------------------------------
Jude Ighomena
Senior Manager, Core Network Operations
Broadbased Communications Limited
Lagos, Nigeria
+2348163474613
------------------------------