Running a script when a job completes

In many scenarios, when a job completes, you might want to run one or more actions, by using the information related to the job completion. For this purpose, you can write a script file and store it in a directory of the agent file system. The script is run every time that a job completes, either successfully or unsuccessfully. The script runs with the same credentials as the agent user that is running the job.
Note: The agent user must be authorized to access the script file and its directory.
To provide HCL Workload Automation with the path of the script file, you must modify the JobManager.ini file as follows:
  1. Locate the JobManager.ini file on the local agent instance where the script will run. The file is located in the TWA_home/TWS/ITA/cpa/config directory on the agent.
  2. In the [NativeJobLauncher] section of the file, define the value of the PostJobExecScriptPathName property, with the fully qualified path of the script file that you want to run when a job completes.
  3. Save the changes to the file.
If you do not specify any file path or the script file doesn't exist, no action is taken when the job completes. For details about customizing the PostJobExecScriptPathName property, see Administration Guide.
The following job variables can be used in the script:
  • JOB_ID
The script is run for any of the following job final statuses:

In the JobManager_message.log, you are notified via a message if the job started successfully, or if any error prevented the job from starting. To analyze the output of the script execution, you can check the out.log file in the post_script subdirectory of the job SpoolDir.