Hi All,
I need to create a job , if the job ended not ok then next job should trigger.Please help
Thanks
How to create job with NOT OK out condition
JOB ENDED NOTOK
BE VERY CAREFUL how you do this.
- It is not a good practice never to just do an OK when a job fails so that you can run the next job.
- It is also not a good pratice to create a condition that makes it look like the job has succeeded (such as JOBA-OK when JOBA fails).
The above methods can affect other jobs that may depend on your job (or other jobs that you may add later that depend on your job).
It is better to have a standard where you create a condition JOBA-OK where JOBA succeeds and JOBA-NOTOK (or similar) when JOBA fails.
Then you can make a dependencies work how you need in the in-conditions of any subsequent jobs:
- Job dependent on JOBA-OK - runs when JOBA completes successfully.
- Job dependent on JOBA-NOTOK - runs when JOBA fails.
- Job dependent on JOBA-OK or JOBA-NOTOK - run when JOBA completes (whether successful or not).
- It is not a good practice never to just do an OK when a job fails so that you can run the next job.
- It is also not a good pratice to create a condition that makes it look like the job has succeeded (such as JOBA-OK when JOBA fails).
The above methods can affect other jobs that may depend on your job (or other jobs that you may add later that depend on your job).
It is better to have a standard where you create a condition JOBA-OK where JOBA succeeds and JOBA-NOTOK (or similar) when JOBA fails.
Then you can make a dependencies work how you need in the in-conditions of any subsequent jobs:
- Job dependent on JOBA-OK - runs when JOBA completes successfully.
- Job dependent on JOBA-NOTOK - runs when JOBA fails.
- Job dependent on JOBA-OK or JOBA-NOTOK - run when JOBA completes (whether successful or not).
I fell that a better approach is to look for specific values in COMPSTAT. The majority of our jobs are coded to end NOTOK if anything other han zero is detected. However, we do have some jobs setup that take different actions based upon various values.
We also learned an interesting lesson a couple of months ago. COMPSTAT sometimes has a value that was set by the OS of the agent machine rather than the script that it was supposed to execute. I don't remember the exact details of what happened. I happened to show the value of COMPSTAT from one job to a UNIX administrator and he recognized the code immediatly.
We also learned an interesting lesson a couple of months ago. COMPSTAT sometimes has a value that was set by the OS of the agent machine rather than the script that it was supposed to execute. I don't remember the exact details of what happened. I happened to show the value of COMPSTAT from one job to a UNIX administrator and he recognized the code immediatly.
BEST APPROACH
Maurizog,
You are entitled to disagree, but think about what you are suggesting - to create a condition that reflects something that isn't true. In relation to maintenance it can be confusing.
And what happens if another job is dependent on the first job succeeding - if you've created an -OK condition on failure how can you do that unless you have a good set of strict standards, as I have suggested. There are other ways to do it but they are even more confusing.
Remember - any method that follows set standards is better and makes your system easier to maintain, especially for the person that comes into the job after you.
You are entitled to disagree, but think about what you are suggesting - to create a condition that reflects something that isn't true. In relation to maintenance it can be confusing.
And what happens if another job is dependent on the first job succeeding - if you've created an -OK condition on failure how can you do that unless you have a good set of strict standards, as I have suggested. There are other ways to do it but they are even more confusing.
Remember - any method that follows set standards is better and makes your system easier to maintain, especially for the person that comes into the job after you.