Sunday, March 25, 2012

Cleanup Prerequisite Conditions

To delete conditions > 3 days old and less than 10 days old.
Have a command job that executes the following command:

ctmcontb -DELETEFROM "*" %%A %%B

On the SET tab we have the following:

B %%CALCDATE %%DATE -3
A %%CALCDATE %%DATE -10
B %%SUBSTR %%B 3 4
A %%SUBSTR %%A 3 4

Killing long running jobs automatically

1. Set up a 'shout' destination that maps to a 'p' (for program) on the Control-M Server.
2. On Unix your shout destination script would be something like this -

#! /bin/csh
ctmkilljob -ORDERID $2 &
ctmshout -ORDERID $2 -USER ECS -MESSAGE "Long running job killed" -SEVERITY R &

The first line does the cancel, the second line will send an alert to the ECS console.

3. On the Post Processing panel put this destination in the 'to' field and (importantly) have the message field as just %%ORDERID - then fill in the 'when' and 'param' fields as desired (e.g. Exectime & >010 will mean that your job gets cancelled if it runs longer than 10 minutes).

May be Conditions...

Step1
Define your milestone job with an IN conditions for all jobs that you want to check like this:

1) Name of conditions for daily jobs: Jobx-Ok ODAT
2) Name of conditions for monthly jobs : #-Jobx-Month-Ok ODAT
3) Name of conditions for weekly jobs : #-Jobx-Week-Ok ODAT

<#-Condition name> is a prefix to define maybe contitions

Step 2
Define your jobs (weekly and monthly) with OUT condition to respect this convention prefix < #-Condition name >

Step 3
Define a job (Job1) to invoke the utility with parameter -CALCCOND -ADDMODE NO
This utility create a default output file in

Step 4
Define a job (Job2) to invoke the utility with parameter -LOAD "#-*"This utility read the conditions from a default file and load it on Conditions/Resources table

Important:
- Job1 and Job2 must be run after your
- Job2 must be run after Job1

See CTM_SERVER admin guide (utilities/ctmldnrs)

Example: Your daily milestone job check all regular daily conditions and conditions like < #-Condition name >

If a job with OUT conditions like < #-Condition name > not run due to schedule specifications you find this sysout for Job1

Job1

+ ctmldnrs -CALCCOND -ADDMODE NO

DEFAULT OUTPUT file is /soft/ctm01/ctm/tmp/ctmldnrs.dat
Previous output file /soft/ctm01/ctm/tmp/ctmldnrs.dat is deleted.
--------------------------------------------------------------
CONDNAME DATE ORDERNO JOBNAME
--------------------------------------------------------------
Q01-JOB37-BA-OK 0814 2600753 Q01-JOB13 \
#-F01-JOB14-OK 0814 2600655 F01-JOB05-I05 \
#-F01-JOB34-OK 0814 2600655 F01-JOB05-I05 \
#-Q01-EMM08-OK 0814 2600242 Q01-EMM14 \
#-Q01-EMM12-OK 0814 2600242 Q01-EMM14 \
Q01-AVAMO-H-OK 0814 2600770 Q01-FMC64-A05 \

After Job2 you find this in sysout for Job2

Job2

+ ctmldnrs -LOAD #-*

The INPUT file is /soft/ctm01/ctm/tmp/ctmldnrs.dat
+ ctmldnrs -LOAD #-*
Condition #-F01-JOB14-OK is loaded
Condition #-F01-JOB34-OK is loaded
Condition #-Q01-EMM08-OK is loaded
Condition #-Q01-EMM12-OK is loaded

The missing conditions < #-Condition name > was created (ADDED) because nothing jobs with this OUT conditions was scheduled and your milestone job can be executed

In finality the milestone job run every day with all IN conditions.
When the weekly or monthly jobs are scheduled the OUT conditions < #-Condition name > are posted by this jobs
When this jobs are not scheduled, the OUT conditions < #-Condition name > are posted by utility.