Page 1 of 1

automatic clearing job logs by routine?

Posted: Thu Mar 17, 2005 4:03 am
by branimir.kostic
Hello,

is there any way to delete all job logs in a project by a command, routine or something like this?
We have several jobs creating job logs over 1 GB (in case of warnings). Before restarting the jobs I want to clear the logs but it is hard to do it manually and the provided auto purge does not meet the requirements. I just need a 'command' to set it as after job routine. Can you help me?

Thanks.

Regards,
Branimir Kostic

Posted: Thu Mar 17, 2005 4:36 am
by ray.wurlod
Yes, it can be done.

Others will post suggestions that use CLEAR.FILE; please try to avoid that, as you also lose all the control records. And purging the log of a running job has potential hazards; after all, that log is still being updated if you access it from an after-job subroutine. It is better to purge it from a separate job.

I have not checked, but would imagine that if you search the forum you will find sample code. You could also enable server-side tracing, start a Director client, purge the log from there, shut down Director, disable server-side tracing, and inspect the trace file to determine the helper subroutines that DataStage calls to purge a log.

But why are you getting all these warnings?! A wiser approach would also include not generating warning errors; identify the cause and remove the cause. In development, only process a small number of rows rather than millions; abort after a small number of warnings (in development).

Posted: Thu Mar 17, 2005 4:49 am
by branimir.kostic
Hi Ray,

thank you for your reply. In normal case there shouldnt be any warnings or in some cases only a few ones. But after fixing activities I got in a few jobs a huge amount of warnings which makes it sometimes unpossible to open the job logs and it is also very uncomfortable to purge every log manually. It would be perfect and much easier to purge all logs automatically in a separate job in order to fix as soon the job and to restart it.

I already searched here for a code but i havent found something yet :cry:
But I'll try the way you described in order to find out the DataStage subroutines.

Posted: Thu Mar 17, 2005 5:18 am
by ray.wurlod
What you will need is a stand-alone job that consists solely of job control code.
This code loops through all jobs in the project, determining the name of the log file, then purging that log.

Code: Select all

Open "DS_JOBS" To DSJobs.fvar
Then
   ClearSelect 9
   SSelect DSJobs.fvar To 9
   Loop
   While ReadNext JobName From 9
      If JobName Matches "1A0X"
      Then
         ReadV JobNumber From DSJobs.fvar, JobName, 5
         Then
            LogName = "RT_LOG" : JobNumber
            Open LogName To Log.fvar
            Then
               FileLock Log.fvar
               Read PurgeSettings From Log.fvar, "//PURGE.SETTINGS" 
                  Else PurgeSettings = 0 : @FM : 0 : @FM : 0
               Perform "CLEAR.FILE " : LogName
               Write PurgeSettings To Log.fvar, "//PURGE.SETTINGS" 
               Write 1 To Log.fvar, "//SEQUENCE.NO"
               Write "Log purged by routine." To Log.fvar, 0
               FileUnlock Log.fvar
               Close Log.fvar
            End
         End
      End
   Repeat
   Close DSJobs.fvar
End

Posted: Thu Jan 16, 2014 12:51 pm
by haylo75
This is very handy, thanks for posting, Ray. I can see a a few adjunct uses for code like this, namely detecting en masse which jobs override project-level settings.