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
automatic clearing job logs by routine?
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 13
- Joined: Thu Nov 04, 2004 4:30 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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).
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).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 13
- Joined: Thu Nov 04, 2004 4:30 am
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![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
But I'll try the way you described in order to find out the DataStage subroutines.
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
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
But I'll try the way you described in order to find out the DataStage subroutines.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.