Tuesday, June 16, 2009

Reset scheduling job if server rebooting

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

What is my blog

I'm working with IBM Websphere Datastage 8.0 Server Edition.
In this blog, I posted the interesting thoughts and findings obtained during the work with Datastage.