Clearing out old running and unknown jobs

Tools and several solutions to manage Control-M products
Post Reply
User avatar
Deano
Nouveau
Nouveau
Posts: 42
Joined: 03 Jul 2006 12:00
Location: London´

Clearing out old running and unknown jobs

Post by Deano » 11 Sep 2009 1:57

Hi All,

We have a test environment which is getting quite messy. There are lots of jobs that are running, running and held, unknown......

These are running accross 5 servers and on many different agents, so recycling the agent status is not a quick win.

Any ideas on the best way to clear out all jobs, regardless of status, once they are 3 days old?

thanks
Deano

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

Post by philmalmaison » 11 Sep 2009 2:22

you can do the following :
hold delete each day the jobs with odat > <date>
is is what i do for that (taken in a contest)
calcule_date () {
shift=${1}
ctmcalc_date -SCHEDTAB LEURRE -JOBNAME "*" -DATE `date +'%Y%m%d'` -SHIFT ${shift} -ONLY_WORKING_DAYS N -OUTPUT_FORMAT DATE
}
#creation table Leurre maintenance pour ctmcalc_date
ctmdefine -TABLE LEURRE\
-JOBNAME Leurre_Maintenance\
-TASKTYPE DUMMY\
-GROUP LEURRE\
-APPLICATION LEURRE\
-OWNER ${owner}\
-AUTHOR ${owner}\
-DAYS ALL\
-DESCRIPTION "Job de Leurre pour le ctmcalc_date"
#menage proclog avant traitement
menage_avant_trait "CTMPSM KILL CS*log WD*log ecsprflag u_jsa";

#liste des odat a exclure du traitement de purge jobs
liste_odat_to_keep ${keepdays};

#
#traiement du nettoyage de l AJF
#
echo "Debut traiement du nettoyage de l AJF : `date +'%H:%M:%S'`" >> ${fic_main}
liste_ign="RMAN"
ctmpsm -LISTALL -ALLFIELDS -SORT ORDERID | \
grep . | \
egrep -v "\-\-|ORDERID" | \
egrep -v "${liste_ign}" | \
egrep -v -f ${tmp1} | \
awk '{print $1" "$2" "$3" "$4" "$5" "$6}' > ${tmp2}
cat ${tmp2} | while read job_to_manag
do
order=`echo ${job_to_manag} | awk '{print $1}'`
jname=`echo ${job_to_manag} | awk '{print $2}'`
jtype=`echo ${job_to_manag} | awk '{print $3}'`
jdate=`echo ${job_to_manag} | awk '{print $4}'`
jstate=`echo ${job_to_manag} | awk '{print $5}'`
case ${jstate} in
Executin)
echo "job ${jname} odate ${jdate} etat ${jstate} kill job en cours de traitement..." >> ${fic_main}
ctmkilljob -ORDERID ${order}
sleep 2
ctmpsm -UPDATEAJF ${order} FREE
;;
*)
echo "job ${jname} odate ${jdate} etat ${jstate} hold delete en cours de traitement..." >> ${fic_main}
ctmpsm -UPDATEAJF ${order} HOLD
sleep 2
ctmpsm -UPDATEAJF ${order} DELETE
;;
esac
done
rm ${tmp1} ${tmp2}
echo "Fin de traitement du nettoyage de l AJF : `date +'%H:%M:%S'`" >> ${fic_main}



take what you want


regards
philmalmaison

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

Post by philmalmaison » 11 Sep 2009 2:26

for jobs in status unknown you can detect them by doing a cyclic job scanning AJF, and giving JOBNO, or ORDERNO.
i think it is really easy to shout concerned jobno and orderid to a program doing the necessary to be in anothere state after ...
so
update CMR_AJF set STATE = '5', OSCOMPSTAT=1, STATUS='N' where ORDERNO = <number>



pour info state

wait scheduling -> 0
wait confirm -> 1
submitted -> 2
not submitted -> 3
executing -> 4
ended -> 5
analyzed -> 6
disappered -> 7
post processed -> 8
Not found -> 9
wait rerun -> A
wait time -> B
wait cond -> C
wait ressource -> D
wait submission -> E
not known -> F
retry submit -> G
wait group sch -> H
fail submit -> I
unknown -> Z



regards
philmalmaison

User avatar
Deano
Nouveau
Nouveau
Posts: 42
Joined: 03 Jul 2006 12:00
Location: London´

Post by Deano » 11 Sep 2009 3:23

Thanks very much Phil.

Post Reply