5.8.2 Defining the job end condition
You use the #-adsh_job_stop command to define the condition to be used to determine whether the job is to be cancelled when a job step terminates.
- Organization of this subsection
(1) Timing of evaluation
Each time a job step terminates, JP1/Advanced Shell checks if the return code for this attribute is defined. If such a return code is defined, JP1/Advanced Shell terminates the job without executing the subsequent job definition scripts.
(2) Scope
The end condition applies to execution of job definition scripts starting at the location immediately following where it is specified. If this command is specified in the preceding job definition script, that specification is reset and only the new condition specified takes effect.
The following shows an example.
01: #!/opt/jp1as/bin/adshexec 02: #-adsh_job JOB0001 03: 04: #-adsh_step_start STEP1 05: #-adsh_step_end 06: 07: #-adsh_job_stop 4:The scope of this definition is from line 09 through 13. 08: 09: #-adsh_step_start STEP2 10: #-adsh_step_end 11: 12: #-adsh_step_start STEP3 13: #-adsh_step_end 14: 15: #-adsh_job_stop 8:16,24:32
The scope of this definition is from line 17 through 18. 16: 17: #-adsh_step_start STEP4 18: #-adsh_step_end
(3) Example of job end condition definition
If the #-adsh_job_stop command is used to define a job end condition, the following occurs:
Even if a job step terminates with the return code specified in the #-adsh_job_stop command, commands outside the job step do not cancel the job.
If a job step terminates with the return code specified in the #-adsh_job_stop command, the job step cancels the job.
If a job is cancelled by executing the #-adsh_job_stop command, any subsequent commands outside the job step are not executed. The subsequent job steps are not executed either, regardless of the specification of the run attribute.
The following shows an execution example.
#-adsh_job JOB_STOP #-adsh_rc_ignore CBLRTN #-adsh_job_stop 4Specifies that the job is to be cancelled at rc=4. echo "Job start." CBLRTN 004 # Command that succeeds at rc=4
The job is not canceled although a command outside the job step results in rc=4. #-adsh_step_start STEP01 echo "Step start." CBLRTN 004 # Command that succeeds at rc=4 #-adsh_step_end
The job step terminates with rc=4 and the job is cancelled. #-adsh_step_start STEP03 -run always
Does not execute any subsequent job steps regardless of the run attribute. echo "command in step" #-adsh_step_end echo "Job end."
Does not execute any subsequent commands.