admin Site Admin
Joined: 21 Jun 2005 Posts: 209
|
Posted: Mon Jul 24, 2006 4:39 pm Post subject: Deleting archived mails |
|
|
Hello everybody on the list. I thought I post an update of my problem
and its current work-around.
The goal was to delete archived e-mails which are older than xx days.
The machine archives roughly 2-5 GB of data / day of 400+ users.
The e-mail are archived on a daily basis foldername something like YYYY-MM.
First approach:
find /mailarchive/ -mtime +30 -type f -exec /bin/rm -rf {} \;
didnt work as expected. The command doesnt cope with the amount of small files
Second approach:
find /tmp/test/ -mtime +30 -type f | xargs /bin/rm -f
Also didnt work. Probably same cause as the first approach.
My guess is that the commands arguements passed from find to xargs is
just to much for the commands arguments buffer of the OS.
Anyway I got those valuables replies from Greg,Devdas,Scott and Jorey.
So unfortunately I cant change the way the data is archived, because
it is a commercial solution (bad enough ;- ( ).
So I have to life with the structure and go from there. After some
going inside of me I came up with looking for the structure in which
the files are stored.
Evt. after some trial and error I figured that its best to approach it
by the folders names instead of the files metadata.
So I finally ended up with a simple command like
rm -rf /mailarchive/`date -d '1 month ago' +%Y-%m`/`date -d '1 month
ago' +%Y-%m-%d`
which works now beautifully.
date -d '1 month ago' +%Y-%m will output something like "2006-06"
which is the folders name and analog to it "date -d '1 month ago'
+%Y-%m-%d" will name and remove the subfolder.
That is the closest that I could come up with for now.
I guess I have to leave the fun of debugging the command line buffers
for a boring weekend in the cold winter
Once more thank you for any replies, it was much appreciated.
Best regards
Nils Valentin |
|