How to configure Control-M/Server to execute a SHOUT that will kill a job which has been running for too long automatically? - INCLUDES VIDEO
Knowledge Article
How to configure Control-M/Server to execute a SHOUT that will kill a job which has been running for too long automatically? - INCLUDES VIDEO
How do configure Control-M/Server to execute a SHOUT that will kill a job which has been running for too long automatically?
Control-M/Server for UNIX and Microsoft Windows
Control-M/Server for UNIX and Microsoft Windows
All versions of Control-M/Enterprise Manager and Control-M/Server
Control-M/Server for UNIX and Microsoft Windows
Control-M/Server for UNIX and Microsoft Windows
All versions of Control-M/Enterprise Manager and Control-M/Server
- How to configure Control-M/Server to automatically kill jobs which have been running for too long? - How to configure Control-M/Server to perform a SHOUT automatically to kill a long running job? - How to define a SHOUT destination and add it to a Control-M Job that will be execute the SHOUT automatically?
- The following steps explain a possible solution that will enable Control-M/Server to automatically kill jobs which have been running for too long. - When the job exceeds its time window, it will perform a SHOUT to a script. - This script will execute the utility "ctmkilljob".
The following video demonstrates this solution:
Step 1: Define the Shout Destination
- On the Control-M Server, enter "ctmsys" - Select "Shout Destination Tables" and define a Shout Destination with following details Type: Select "P" for "Program" Address Type: Choose either "S" (Server) or "A" (Agent) depending where is the location of the script Logical Destination: Give a logical name for this SHOUT which will be used in the Control-M Job Definition Physical Destination: Include the Full Directory Path and File Name of the script UNIX: <Full Directory Path>/<Script Name>.sh Windows: <Full Directory Path>/<Script Name>.bat
NOTE: On Microsoft Windows, the short filename (in 8.3 notation) is required. To determine this, use the following command: cmd /c for %A in ("{long filepath}") do @echo %~sA
For example, if the long filepath is C:\Program Files\BMC Software\Control-M Server\ctm_server\scripts\killjob.bat, then you would run: cmd /c for %A in ("C:\Program Files\BMC Software\Control-M Server\ctm_server\scripts\killjob.bat") do @echo %~sA
The output would show something like this: C:\PROGRA~1\BMCSOF~1\CONTRO~1\CTM_SE~1\scripts\killjob.bat You would set the above output, the short filename, as the value in the shout destination definition, rather than the long filename.
An example as below:
Shout Destination Table 'SYSTEM'
------------------------------------
# Destination Type Adr Logical Name Physical Name
--- ---------------- --- ----------------- ------------------------------------
1 O S CONSOLE
2 E S ECS
3 L S IOALOG
4 P S Kill_Job /apps/controlm/ctm/scripts/killjob.sh
Step 2: Create the killjob.sh script (or any other script)
UNIX: - Go to your Control-M/Server home directory (or any directory) - Define a script under ctm_server/script/ - The script name will be "killjob.sh" as defined in Step 1 - Below is the contents of the "killjob.sh" script: #!/bin/sh ctmkilljob -ORDERID $2 & - Note the ampersand (&) at the end of the ctmkilljob command. This must be present for this solution to work. - Set the "execute" authorization for this script. When in doubt, use the command: chmod 775 killjob.sh
Windows: - Go to your Control-M/Server home directory (or any directory) - Define a script under the selected directory - The script name will be "killjob.bat" as defined in Step 1 - Below is the contents of the "killjob.bat" @ECHO OFF cmd /C ctmkilljob -ORDERID %2% - The /C switch that tells windows to open a command shell, run the command and close
Step 3: Define the Control-M jobs that would use this automatic kill mechanism on, do the following:
For Control-M EM V7: - Launch Control-M Desktop - Edit the job properties - Go to the "PostProc" tab - Define a SHOUT by specifying "WHEN LATETIME" or "WHEN EXECTIME" - Enter "Kill_Job" (Logical Destination defined in Step 1) in the SHOUT "To" Destination - Enter "%%ORDERID" for the "Message" field ()which will become the parameter for the "killjob.sh" script).
For Control-M EM V8 and above: - LaunchWLA GUI > Planning Domain - Edit the job properties - Go to the "Action" tab (V8 and above) - Click the "+" icon for beside the "Notification before job completion" - Define "Job's execution time" or "Job not finished by <time>" option for "When" field - Select or type "Kill_Job" (Logical Destination defined in Step 1) for the "Destination" field under "Send Notification To:" - Enter "%%ORDERID" for the "Message" field (which will become the parameter for the "killjob.sh" script). - Select the desired "Urgency" level
Control-M/Server for UNIX and Microsoft Windows
Control-M/Server for UNIX and Microsoft Windows
All versions of Control-M/Enterprise Manager and Control-M/Server