Checkpoints
adTempus provides the capability of restarting jobs that were interrupted due to a system shutdown or failure. In such cases, though, you may not want to start executing your task from the beginning in the event of a restart.
For example, if you have a batch file that executes several different commands, you may want to skip the commands that completed before the failure.
Checkpoints provide a means of doing this. As your program, batch file, or script executes, it can periodically pass a checkpoint value to adTempus (this can be any string that will be meaningful to your program). If adTempus subsequently restarts the job after a failure, it will pass back the latest checkpoint it received; your task can use that to resume execution at the correct place.
The method for getting and setting the checkpoint depends on the kind of task you are executing:
- Batch files should use the adtChkpt utility program.
- Scripts (as long as they are run by an adTempus Script Execution task) can use the Checkpoint variable.
- Applications can retrieve the checkpoint by using Windows API functions to retrieve the "ADTJobCheckpoint" environment variable. To set the checkpoint the application must use the programming interface to the adTempus engine.
Viewing Checkpoints
The History Panel and Job Monitor View both have a column that shows the most recent checkpoint for an active job. You can also view the most recent checkpoint of an active or completed instance in the Job Instance Properties window.
Example: Using Checkpoints in a Batch File
When you run a batch file using the internal batch file option in a Program Execution Task, adTempus can automatically insert checkpoints for you. When you use this option, you can leave out the calls to "adtchkpt" shown in the example below: adTempus will insert a call right after each label when it runs the batch file.
The following template shows how to use checkpoints effectively in a batch file.
@echo off if not "%ADTJobCheckpoint%" == "" goto %ADTJobCheckpoint%
:runimport "%ADTServerPath%\adtchkpt" /s "runimport" "c:\my programs\importdata.exe" 1234
rem Be sure to change both the label and the adtchkpt parameter for each rem checkpoint. :createreports "%ADTServerPath%\adtchkpt" /s "createreports" "c:\my programs\createreports.exe" 1234
When adTempus runs a program or batch file with a resume checkpoint set, that checkpoint value is stored in the ADTJobCheckpoint variable. The second line of the batch file checks for that variable:
if not "%ADTJobCheckpoint%" == "" goto %ADTJobCheckpoint%
If the variable is set, the batch file jumps to the label that has the same name. Otherwise, the batch file continues execution from the beginning.
For each major command or section of your batch file, you define a label (to be used as the goto target if the step is rerun from that checkpoint) and pass the same value to adTempus as the latest checkpoint.
This line defines the label:
:runimport
The next line tells adTempus what the current checkpoint is:
"%ADTServerPath%\adtchkpt" /s runimport
The ADTServerPath environment variable is set by adTempus and points to the adTempus installation directory, where the adtchkpt program is located. Running that program tells adTempus what the current checkpoint is for the step.
Note that the label you use in the batch file and the checkpoint value you pass to adTempus must match.