User Tools

Site Tools


Sidebar


Tags Cloud
speedup_rm

Быстрое удаление большого количества файлов

generate files

for i in $(seq 1 1000000); do echo testing >> $i.txt; done

rm

time rm -f *
-bash: /bin/rm: Argument list too long
real    0m11.126s
user    0m9.673s
sys     0m1.278s

find with -exec rm

time find ./ -type f -exec rm {} \;
real    14m51.735s
user    2m24.330s
sys     9m48.743s

find with -delete

time find ./ -type f -delete
real    5m11.937s
user    0m1.259s
sys     0m28.441s

perl

time perl -e 'for(<*>){((stat)[9]<(unlink))}'
real    1m0.488s
user    0m7.023s
sys     0m27.403s

rsync - empty test dir

rsync -a --delete /home/blanktest/ /home/test/
real    2m52.502s
user    0m2.772s
sys     0m32.649s
speedup_rm.txt · Last modified: 2015/02/26 10:20 by kyxap