Linux下如何快速删除海量文件
日常运维中,某些服务器几十万的文件需要删除,该如果快速删除?
rm
[ ~]$ cd test [ test]$ for i in $(seq 1 500000).log;do echo "this is test">>${i}.log;done [ test]$ time rm -f *.log -bash: /bin/rm: Argument list too long
find + delete
[ ~]$ cd test [ test]$ for i in $(seq 1 500000).log;do echo "this is test">>${i}.log;done [ ~]$ time find test/ -type f -delete real 0m25.030s user 0m0.515s sys 0m13.969s
rsync + delete
[ ~]$ cd test/ [ test]$ for i in $(seq 1 500000).log;do echo "this is test">>${i}.log;done [ ~]$ time rsync --delete-before -a empty/ test/ real 0m15.497s user 0m1.175
从测试结果可以看出rsync效率最高
相关推荐
敏敏张 2020-11-11
SCNUHB 2020-11-10
小木兮子 2020-11-11
wwwsurfphpseocom 2020-10-28
WasteLand 2020-10-18
Cocolada 2020-11-12
杜鲁门 2020-11-05
shirleypaddy 2020-10-19
qingmumu 2020-10-19
Testingba工作室 2020-09-15
周公周金桥 2020-09-13
专注前端开发 2020-08-16
emagtestage 2020-08-16
heniancheng 2020-08-15
hanjinixng00 2020-08-12
小方哥哥 2020-08-09
83327712 2020-07-30
卖小孩的咖啡 2020-07-21
wqiaofujiang 2020-07-05