Tracking Methods
A job’s completion status is determined by its exit code. The exit code can be set by using the ocsexit command at the end of a batch file.
Using ocsexit to facilitate job tracking, the completion status of a job can be:
-
Completed Normally indicated by an exit code of 0 to notify that the job succeeded.
-
Completed Abnormally indicated by an exit code 0 to notify that the job ran, but failed.
Note: Completion statuses of Skipped, Orphaned, Error Occurred and Externally Defined are also possible but are not determined by the exit code.
The completion status is frequently used to control dependencies. For example, you can set up jobs that run if its predecessor completes with a Completed Normally status.
Tidal Automation supports four other tracking methods:
-
External – You can use this option if you need to inspect the job before determining how the job completed. Tidal Automation sets the status to Set Externally when the job completes.
-
Exit Code of cmd pipe – You can use this option to pipe the output of your job as an input to a command, such as the Windows Find command or other output analysis tool. Tidal Automation then uses that command’s exit code as the job’s exit code. You must type the command that invokes the associated tool.
-
Scan Output: Normal String – Select this option to use a particular text string in the job output to determine if the job completed normally. Enter the exact text that determines “normal” in the text below.
-
Scan Output: Abnormal String – Select this option to use a particular text string in the job output to determine if the job completed abnormally. Enter the exact text that determines “abnormal” in the text below.
The tracking selections are located in the Tracking section of the Run tab in the Job Definition dialog.
Using the Exit Code
In this section, you will create a Reporting job group with two jobs, Report Writer 1 and Report Writer 2. Each job will use the same command, but will pass a different command parameter. The command parameter is then echoed in the output of the jobs after they complete.To determine whether the jobs completed successfully or not, the jobs will use the Exit code of cmd pipe tracking method using the Windows Find command to search for the saved output. The result of the Find command will determine the job’s final status.
You will set up Report Writer 1 to succeed, and Report Writer 2 to fail. You do this by setting the command parameter for job Report Writer 1 to OK and the parameter for Report Writer 2 to FAILED.
Creating the Reporting Job Group
To create the reporting job group:
-
Click Definitions > Jobs on the Navigation pane to display the Jobs pane.
-
Right-click and click Add Job Group from the context menu.
-
Enter Reporting in the Job Group Name field.
-
Click the Schedule tab, if not already selected.
-
Choose work day from the Calendar Name list.
-
Click OK to save the job group.
-
Click Cancel at the Effective Date dialog.
Note: If you click OK at this dialog, the job group enters the production schedule, but nothing will run because there are no jobs associated with the job group yet. Clicking Cancel means the job group will be added to the schedule manually.
Setting the Report Writer 1 Job to Succeed
To set the Report Writer 1 job to succeed:
-
Right-click the Reporting job group and open Add > Job from the context menu.
-
Enter Report Writer 1 in the Job Name field.
-
Enter the full path to the Argdemo batch file in the Command field.
-
Enter OK in the Command Parameters field. This passes as Argument 1 (%1) to the batch file.
-
Click the Run tab.
-
Choose the Exit code of cmd pipe option in the Tracking section.
-
Type Find “OK” in the text field. This tells TA to search through the output of the job for the string “OK”. Since “OK” is passed as a command parameter, it will appear in the output.
-
Click OK.
-
Click Cancel in the Effective Date dialog. This job will enter the schedule when manually submit its job group.
Setting the Report Writer 2 Job to Fail
To set the Report Writer 2 job to fail:
-
Right-click the Report Writer 1 in the job view.
-
Click Copy Job/Group from the context menu.
-
Double-click the Copy of Report Writer 1 job to open its definition for editing.
-
Change Copy of Report Writer 1 to Report Writer 2 in the Job Name field.
-
Change OK to FAILED in the Command Parameters field.
Note: The Run tab should contain Find “OK” in the Tracking section. This was inherited when you copied the job
-
Click OK
-
Click Cancel at the Effective Date dialog.
Adding the Reporting Job Group to the Production Schedule
To add the Reporting job group to the production schedule:
-
Right-click the Reporting job group.
-
Click Insert Job into Schedule from the context menu.
-
Click OK in the Insert Job Into Schedule dialog.
-
Click OK in the Information dialog.
The jobs start with one completing normally and the other completing abnormally. The job group results in a Completed Abnormally status because one of its jobs completed abnormally.
Setting Report Writer 2 to Complete Normally
To set Report Writer 2 to Complete Normally:
-
Double-click the Report Writer 2 job in the Job Definition dialog.
-
Cchange the Command Parameter value from FAILED to OK in the Job Definition dialog.
-
Click OK.
-
Click OK at the Effective Date dialog.
-
Re-submit the jobs by adding the Reporting job group using the Insert into Schedule option, from the right-click context menu or selecting the option from the Actions main menu.
-
Click OK when the Insert Job Into Schedule dialog appears.
-
Click OK in the Information dialog.
Report Writer 1 and Report Writer 2 complete successfully.