Forcing a Job due to a long running job

All questions about Control-M jobs definitions
Post Reply
User avatar
kylo_h
Nouveau
Nouveau
Posts: 57
Joined: 13 May 2008 12:00

Forcing a Job due to a long running job

Post by kylo_h » 17 Aug 2009 11:48

Hi :D

Is it possible to automatically force in a job if another job runs longer than expected?

Our ctm server is running on Linux, Agent is on Windows 2000 server.

eg: JOB A usually runs for 5 minutes, if it runs for 10 minutes, I want it to force JOB B into the schedule.

User avatar
kylo_h
Nouveau
Nouveau
Posts: 57
Joined: 13 May 2008 12:00

Post by kylo_h » 17 Aug 2009 1:20

anyone???

User avatar
Walty
Nouveau
Nouveau
Posts: 473
Joined: 20 Jan 2006 12:00

Post by Walty » 17 Aug 2009 2:52

Hi,

Step 1) Create a script file accessible by Control-M Serverwith the <execute> authorisation.
In this script put the following commands :

#!/bin/csh
ctmorder -SCHEDTAB <your table> -JOBNAME <your job> -ODATE ODAT -FORCE Y &
The ampersand (&) must be present at the end of the command

Step 2) Create on your Control-M/Server a <new logical shout> in Shout destination table using <ctm_menu> or <ctm_sys>

Setup a shout new destination along these lines:

Destination Type: <Program>
Address Type: <Server>
Physical Name: <Full path name of your script file>

Step 3) In the job that you want to check simply add the following definition in the POST-PROC tab:

When EXECTIME > x minutes
SHOUT to <new logical shout>


This execute your script file defined in step 1
Best regards
Walty

User avatar
kylo_h
Nouveau
Nouveau
Posts: 57
Joined: 13 May 2008 12:00

Post by kylo_h » 17 Aug 2009 3:05

Walty, you are the MAN!!!!!

I've got some other shouts that run a program, but it completely slipped my mind.

Thanks mate!!!

User avatar
markf
Nouveau
Nouveau
Posts: 134
Joined: 13 Jul 2006 12:00
Location: Switzerland
Contact:

Post by markf » 18 Aug 2009 10:03

A similar method can be used for killing long-running jobs. Set up the shout as Walty describes but remember to have %%ORDERID in the Message field.

The script on the Control-M Server would be like -

#! /bin/csh

ctmkilljob -ORDERID $2 &
ctmshout -ORDERID $2 -USER ECS -MESSAGE "Job killed" -SEVERITY R &

the first line does the kill, the second line is just a shout to the console so we know this was necessary.

User avatar
philmalmaison
Nouveau
Nouveau
Posts: 1148
Joined: 08 Jun 2007 12:00
Location: Ile de France

Post by philmalmaison » 18 Aug 2009 11:11

the best way is to create a controlm script, used by the jobs, inwich you can put a shout to Program , when exectime > Xminutes

so define in ctm_menu / parameters / shout dest ... a new virtual name to your scripts with P parameter and path

then when your scpecific job is in exectime as you shout it's %%ORDERID as parm2 for the script, you can automatically do what you want with the job.

ex :
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 XALERT $HOME/ctm_server/scripts/manxal.ksh


and for my case i launch a script putting the job in a particular state for my buisness (you successors won't be schedule)

#!/bin/ksh
log="/tmp/majAJF.txt"
orderid=$2
order_no=`p_36 ${orderid} | awk '{print $3}'`
rm -f ${log} ;
echo "orderid : ${orderid}" > ${log}
echo "order_no : ${order_no}" >> ${log}
echo "global params : $*" >> ${log}
echo "nb_params : $#" >> ${log}

Infos_Exectime () {
SQL -b << EOF
set nocount on
go
update CMR_AJF set STATE = '5', OSCOMPSTAT=999, STATUS='N' where ORDERNO = ${order_no}
go
EOF
}

#
# Main prog
#
Infos_Exectime ;
ctmshout -DEST ECS -MESSAGE "attention job no ${order_no} parms : $* exectime warning" -SEVERITY v



regards
philmalmaison

User avatar
kylo_h
Nouveau
Nouveau
Posts: 57
Joined: 13 May 2008 12:00

Post by kylo_h » 26 Aug 2009 12:11

Thanks Guys!!!!

Much Appreciated

Post Reply