Wednesday, October 3, 2012

Define In/out condition with PRECMD/POSTCMD

Define In/out condition with PRECMD/POSTCMD

%%PRECMD ctmcontb -ADD condition-ok ODAT


Examples

The following command deletes prerequisite condition bckp_end with condition
dates in December:


ctmcontb -DELETE bckp_end “12*"

yoou can define this to PRECMD/POSTCMD.


The following command deletes the prerequisite condition aa* with condition date
ODAT:


ctmcontb -DELETENOWILD “aa*” ODAT

AutoEdit variables (Date and Time)


Few examples:
Below %%BB is resolved to 5PM on current system date
%%AA= %%$CALCDATE %%$DATE
%%BB= %%AA.1700

Below %%BB is resolved to 6:40 AM on next day of current system date
%%AA= %%$CALCDATE %%$ODATE +1
%%BB= %%AA.0640

AutoEdit functions
%%CALCDATEAdds or subtracts a specified number of days from a specified date.

On October 1, 2012, %%A resolves to 120930 in any of the following expressions:

%%A=%%CALCDATE %%DATE -1
%%A=%%CALCDATE 121001 -%%DAY
%%A=%%CALCDATE 120929 +1

%%$CALCDATESame as %%CALCDATE, but handles 4-digit years.

On October 1, 2012, %%A resolves to 20120930 in any of the following expressions:
%%A=%%$CALCDATE %%$DATE -1
%%A=%%$CALCDATE 20121001 -%%DAY
%%A=%%$CALCDATE 20120929 +1

%%SUBSTRExtracts a substring from a specified string.

Syntax:
%%SUBSTR variable start_position length

In the following series of expressions, %%Number resolves to TWO:
%%Nstring=ONETWOTHREE
%%Start=4
%%Number=%%SUBSTR %%Nstring %%Start 3

An example for Date & time.
%%HH %%SUBSTR %%TIME 1 2
%%MM %%SUBSTR %%TIME 3 2
%%SS %%SUBSTR %%TIME 5 2
%%PARM1 %%$OYEAR:%%OMONTH:%%ODAY%%BLANK1.%%HH..%%MM..%%SS
result is : 2012:10:01 10.58.02

Few important Control-M variables


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.