UNIX command for the PS DBA – find

In several of my previous projects, we used to get 4-5 tickets per week because of space related issues. Finally we implemented automated scripts to take care of this issue. The PS_HOME and psreports are the two main directories which have to be monitored for space growth. Below I explain the relevant examples of the UNIX command “find” that you can use to build your shell script.

find $PS_HOME -name ‘*.AET’

The above command will recursively find all files with .AET extension residing in the PS_HOME directory.

find $PS_HOME -name ‘*.AET’ -mtime +1

The above command will recursively find all files with .AET extension and older than 1day in the PS_HOME directory.

find $PS_HOME -name ‘*.AET’ -mtime +1 -exec gzip {} ;

The above command will recursively find all files with .AET extension, older than 1day and will gzip the file in the PS_HOME directory.

find $PS_HOME -name ‘*.AET’ -mtime +1 -exec rm {} ;

The above command will recursively find all files with .AET extension, older than 1day and will remove the file in the PS_HOME directory.

find $PS_HOME -name ‘*.AET’ -size +10000000c -exec gzip {} ;

The above command will recursively find all files with .AET extension, greater than 10MB in size and will gzip the file in the PS_HOME directory.

You can replace AET with trc or out or log as appropriate

Posted by Nitin Pai
Comments (0)
July 17th, 2007

Comments (0)