The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 09-09-2007
nachazo nachazo is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 1
Wink thanks

thank you so much...

with this post i learn the power of xargs....

i make an script and maybe could be useful for you...

itīs checks the size of the directory and if pass the limit, then check the oldest file and delete it...

This procces is in a loop.... when the spaces fit the limits that you previusly input, the scripts stops...

here is the code:


#bin/bash
#valor 0 es ok
#valor 1 es demasiado grande
. /arwebmin/variables/variables.conf
estado=0
LIMIT=1
limite=$syslogsize

while [ "$estado" -lt "$LIMIT" ]
do

size=`du $dir_incoming | cut -f 1`

echo "$size"
if [ $size -ge $espacio_maximo ] ; then
echo "es mayor"
echo "borrando: $dir_incoming$archivo"
ls -tb $dir_incoming | tail -1 | xargs rm -f

else
echo "es menor"
estado="1"

fi

done


---------------------------------

regards!.