PDA

View Full Version : Deleting 1.5 million files



dhav
12th June 2006, 08:06 PM
Ok, so I ran this stress test program (it's called stress), well, I used their example for running the hard drive component, it writes out 13 byte files the whole time it's running. I was not sure how it ran or what happened when it stopped so I wasn't really prepared for what I got: 1.58 million 13 byte files. The files are named stress. and then a00001, a00002 etc, all the way up to stress.ZZZZZ (not quite that high but it would reach there eventually) (stress.kS2Gyw for example).

So, first thing I tried was rm -rf ./stress.* No go, rm complained the list was too long! I've never even seen that! :) So I wrote a small script to delete these files with some wild cards but it's HORRIBLY inefficient. So, if anybody knows a better/fast way or knows of a way to refine this script, I'd love to hear it! Right now I've been running for about an hour and still have 1.2 million files left.. sigh :)

Thanks for any advice!
d.


#!/bin/bash

a=(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
b=0

c=(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
d=0

for i in ${a[@]}
do
for j in ${c[@]}
do
echo $i$j
done
done

bob
12th June 2006, 08:13 PM
Not a coder, I'm afraid. Just curious though - what would happen if you moved the rm -rf ./stress.* out one place (ie: rm -rf ./stress.a* ) and followed it by the rest of the alphabet? Still too much?

dhav
12th June 2006, 08:22 PM
Not a coder, I'm afraid. Just curious though - what would happen if you moved the rm -rf ./stress.* out one place (ie: rm -rf ./stress.a* ) and followed it by the rest of the alphabet? Still too much?

Yup, that's why I had to do that second level.. I guess I should have mentioned that :)

bob
12th June 2006, 08:25 PM
Out of curiosity, was this program designed to test stress on the machine or on the user? Looks like the machine passed... :D

dhav
12th June 2006, 08:29 PM
Out of curiosity, was this program designed to test stress on the machine or on the user? Looks like the machine passed... :D

Haha.. The best part about this is that I already have a standard set of test tools; linpack for cpu/mem/switch overal performance, ttcp for network, bonnie for hard drives and some custom fortran matracies that fill memory without touching swap. My boss is a bit crazy however, he saw this new test and got all excited even tho it's not clear what it does, how it does it and gives us no metric to comapre the results against other machines of similar build..

management... :)

So now he thinks I'm doing this by hand and that it will take most of the day. At least I can get some reading done.

dhav
12th June 2006, 08:48 PM
oh yeah..

Registered Linux User #239111 ;)

huw-l
12th June 2006, 09:06 PM
find . -name stress.\* -exec rm -rf {} \;

the shell has a fairly low limit (1024?) to the number of arguments it can take on the command line.