Script for Cleaning the Log Files

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Script for Cleaning the Log Files

Post by pradkumar »

Hi

I would like to clear the log files on the unix box.
My box gets always full for every two to three weeks. Then we clear the logs using director and create some space.

I would like to know whether we can create a script and run it so the log files are cleared and whenever the box reaches 98% full, it should send an email alerting"RUN THE LOG CLEAR SCRIPT"

Plz provide any sugestions or ideas
Pradeep Kumar
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Ken, has a utility which will help you with that. Check his website.

It would be a better practice to set up purge settings, so that the clearing of the logs happens automatically.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

A monitoring service should already be in place by your SA. Adhere to the purge settings, also make sure you archive temp files and delete them regularly.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Setting up the auto purge option in the director will be the best approach. If CLEAR.FILE option is used, it will remove the autopurge property.
Also clear the %PH% directory regularly. Delete the orphaned jobs.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Or you can tweak and use Kim's code for this purpose.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

Thanks for all of your ideas.

Actually, for my project I am setting up the auto purge.
The actual scenario is that there are some files of last year and I need to clean up them.

Also I am looking for one script which does it.I will visit ken site once
Pradeep Kumar
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Or the code provided by Ray.

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
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Clearing the DataStage logs won't recover all that much space. Make sure that &PH& and the directory pointed to by UVTEMP are kept as clean as possible too. Also periodically clean up any log/data files used by database utilities and which are no longer needed.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I do not use the code posted. I doubt if Ray uses his. If you are running out of space because of log files then you have bigger problems. I like the autopurge settings. You need to get rid of any warning that you can.
Mamu Kim
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

How to get to UVTEMP (I mean path)

Right now I am searching with Ascential/DataStage/DSEngine/..

But UVTEMP is not fouond
Pradeep Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

UVTEMP is a setting in the uvconfig configuration file. You can get its value using the analyze.shm command.

Code: Select all

$DSHOME/bin/analyze.shm -t | grep UVTEMP
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

Thx ..Thanks a lot

Having one more question.
When I login to my &PH& directory, there were many DSD.RUN_nnnn_nnnn

Q1) Whta this DSD.RUN stands for
Q2) How to delete them based on user name instead of one by one. Like one user "yyyy" has 100 files
Pradeep Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

1. DSD.RUN is the command DataStage uses to run server jobs. DSD.StageRun is the command DataStage uses to execute code generated by server Transformer stages. Files in &PH& with names ending in "trace" are from stage tracing.

2. Use the find command, filter on owner name, and exec the rm command.

Code: Select all

cd '&PH&'
find . -user yyyy -exec rm {} \;
Last edited by ray.wurlod on Fri Feb 09, 2007 2:11 am, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Ray mean to say, find all the files created by particular and delete it.
find . * -user yyyy -exec rm {} \;
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No I didn't. The asterisk is wrong. The dot was missing; I have edited my previous post to include it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply