Hi
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.
Forcing a Job due to a long running job
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
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
Walty
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.
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.
- philmalmaison
- Nouveau
- Posts: 1148
- Joined: 08 Jun 2007 12:00
- Location: Ile de France
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
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