'Use of parallel find to release space in filesystem (Oracle RAC enviroment)

I've written a command in crontab for deleting files older than 1 day with extensions ".trc.[0-9]+.lck .trc .aud .trm .log .xml .dbf" in some directories (diag/ log/ trace/ dbs/ audit/ adump/ alert/ cdump/).

This command release space in an Oracle RAC enviroment, and a later step of complexity is executing the above command in all nodes of the cluster.

This is the whole command:

for i in host1 host2 host3 host4 ; do ssh $i 'for d in `find /u01/ /home/ 
-regextype sed -regex ".*\.trc\.[0-9]\+\.lck$\|.*\.trc$\|.*\.aud$\|.*\.trm$\|.*\.log$\|.*\.xml$\|.*\.dbf$" 
-exec dirname '{}' \; | grep -e "diag/" -e "log/" -e "trace/" -e "dbs/" -e "audit/" -e "adump/" -e "alert/" -e "cdump/" | sort -u`;do 
for f in `find $d -regextype sed -regex ".*\.trc\.[0-9]\+\.lck$\|.*\.trc$\|.*\.aud$\|.*\.trm$\|.*\.log$\|.*\.xml$\|.*\.dbf$" 
-mtime +1`;do
file=`basename $f` ;
\rm -f $f;
echo "N:$i F:$file D:$d" ;
done;
done'
done

The problem is it takes very long time. Is it a way to accelerate the process making use of paralellism or rewritting the command in any form?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source