Page 1 of 1

Stop the sequence at specific time

Posted: Thu Jul 01, 2010 2:29 am
by SachinCho
I have a datastage sequence which runs for 24 hours. I want stop this job on friday night and restart again on monday morning. Restarting can be done manually. Any pointers how to stop at specific time? This should be graceful exit and job should be in stopped/restartable state and not in aborted.

Posted: Thu Jul 01, 2010 3:12 am
by ray.wurlod
Depends, but almost certainly not. A sequence spends most of its time uninterruptably asleep waiting for activities to finish. If you check the system time after each activity finishes you can direct control to an "ending" path. The more complex the sequence, the more additional activities you will need to implement the design.

You can use a job control routine using the sequence generated code as the prototype, and replace the DSWaitForFile() function with our own code that checks the time at each pulse of the "busy wait". But what do you want to happen to activities that are already running in this case?

Posted: Thu Jul 01, 2010 3:12 am
by priyadarshikunal
I think you won't be able to restart a sequence from the point you stopped as stopped/restartable status is not a valid restartable status prior to 8.x.

Posted: Thu Jul 01, 2010 5:38 am
by chulett
As Ray notes, you need to build that functionality in. I always have some kind of "date/time/loop" check built in so it can gracefully stop on its own and add a polling step so I can touch a stop file into existence and it will notice and again do a graceful shutdown.

Posted: Thu Jul 01, 2010 5:45 am
by ArndW
On option is to have another process issue a STOP request at a given time, the job sequence will the sto the next time it polls, or you can use the DSGetJobInfo(JobHandle,DSJ_JOBCONTROL) call to check to see if a stop request is pending.

Posted: Thu Jul 01, 2010 5:51 am
by Sainath.Srinivasan
As everyone will say and agree, a graceful termination is better than killing the process. Also it is cleaner to maintain without any threads hanging.

One possibility I thought about is to decrease the priority of DataStage with Unix nice command to such a level that the OS will not even bother about it.

Alternatively you can schedule a non-DataStage command with high priority during the weekend to keep all other process asleep.

But note that this is your OS level and impacts all other process too.

Posted: Thu Jul 01, 2010 8:08 am
by rameshrr3
I had done this around 4 years ago with datastage sequences and datastage Command lineinterface. Create a scheduled job that will create a dummy file whenever the main sequence needs to be stopped, introduce a wait for file condition in a loop wrapping the main sequence , when file is found use a command activity to stop the job using

Code: Select all

dsjob -stop 
( I know there is a way to stop a job using dsjob - you could get it in the documentation..), and optionally cleanup the dummy file with another command ..

HTH

Ramesh

Posted: Thu Jul 01, 2010 8:19 am
by chulett
Or just exit the loop cleanly when your stop condition (whatever it is) is found. No need to do anything less graceful, really. IMHO. :wink: