Thursday, 9 February 2012

Reset scheduling job if server rebooting ....Datastage related

Some time I have a problem with scheduled jobs - if server was restarted while job running - job status after this become aborted and schedule don't work. For solve this problem I write a routine to reset job if it's status is aborted. I schedule it for 5 minutes before start of main job.

Parameter: jobname - name of reseting job

$INCLUDE DSINCLUDE DSJ_XFUNCS.H
$INCLUDE DSINCLUDE JOBCONTROL.H

JobHandle = DSAttachJob(jobname, DSJ.ERRNONE)

if JobHandle = 0 Then
Call DSLogFatal('Job ' : jobname :' is not found', 'jobReset')
Ans = 1
End Else
jobstatus = DSGetJobInfo(JobHandle, 1)
if jobstatus <> DSJS.RUNNING Then
Call DSLogInfo('Job ' : jobname :' is not running', 'jobReset')
if jobstatus = DSJS.RUNFAILED Then
Call DSLogInfo('Job ' : jobname :' is aborted. Try to reset it', 'jobReset')
RunErr = DSRunJob(JobHandle, DSJ.RUNRESET)
if RunErr = 0 Then
Call DSLogInfo('Job ' : jobname :' is reset', 'jobReset')
End
End
End
Ans = 0
End

No comments:

Post a Comment