Script with high CPU utilization

Hi All,

i have a script that finds the file with .txt .zip .Z .gzip that are 3 days old in directory /abc/def and removes them

find /abc/def -name '0*.txt' -mtime +6 -exec rm {} \;
find /abc/def -name '0*.zip' -mtime +6 -exec rm {} \;
find /abc/def -name '0*.gzip' -mtime +6 -exec rm {} \;
find /abc/def -name '0*.Z' -mtime +6 -exec rm {} \;

Now the issue is the scripts results in high CPU utilization reaching close to 100%.

How can i optimize my script so that i does not result in high cpu usage.

Please Advice and let me know if any others details are needed.

Note: /abc/def directory contains a lot of files.

If there are lot of files,its definitely going to utilize more cpu

I believe the below form is more efficient

find /abc/def -name '0*.txt' -mtime +6 |xargs rm

and if you don't want this script to affect/trouble some other realtime process you could set less priority to 'find' command using 'nice'

nice find ...

Group all the find commands in a single one :

find /abc/def \(    -name '0*.txt'    \
                 -o -name '0*.zip'   \
                 -o -name '0*.gzip'  \
                 -o -name '0*.Z'  \) \
               -mtime +6             |
xargs rm 

Jean-Pierre.