Solution:
Do the following to rerun or stop cyclic when Control-M cyclic job failed for a number of count:
1. If Control-M Server is on V8 and above, define the following ON-DO Action:
- When "Job's Number of Failures" = "3",
- Stop Cyclic Run / Rerun
2. If Control-M Server is V7, do the following:
- Define the following Post-Execution Command Autoedit to add the value of the Variable %%FailCount (AUTOEDIT) to the SysOut.
%%POSTCMD = echo FailCount%%FailCount
- Define the following ON-DO Actions to increase the value of the %%FailCount
on Stmt=* Code=NOTOK (or on any specific return code)
do Set-Var %%\FailCount= %%FailCount %%PLUS 1
Note: the '\' indicates that the Auto-Edit Variable is a Global Autoedit / Variable parameter
- Define the following ON-DO Actions to stop the cyclic job when the "FailCount<Number>" keyword is found in the sysout:
on Stmt=* Code="*FailCount3*" (Change the number according to the number of failure desired)
do Stop Cyclic / Rerun
- Save, Check In and run this job
The above will define the Control-M Cyclic job to do the following:
- A AUTOEDIT %%FailCount is defined to store the Failure Count
- If the job ended NOTOK, the job will increase the counter for %%FailCount
- Then echo the "FailCount+%%FailCount" into the sysout when the job is executed and failed
- Once %%FAILCOUNT reaches 3, the job will stop the CYCLIC or Rerun
Additional Information:- The AutoEdit Variable is Global, which means it has to be reset back to zero manually before job's scheduled time.
- For example, if the scheduled time is 9AM, then you should create a job run at 8:58AM to set the %%FailCount back to 0.
- If the cyclic job next run is 9PM, then another job should run at 8:58PM to set the %%FailCount back to 0 again.
- There is a RFE to run a cyclic job immediately when using the DO RERUN
CTM-3582 - Request the option to be able to have failed cyclic jobs automatically rerun at the time of failure