Ubuntu quickly deletes a large number of small file methods

Source: Internet
Author: User
Tags rsync

You can do the following two steps:

1, the first step: Create an empty folder: Mkdir/tmp/blank

2. Step Two: Execute the following command: rsync--delete-before-d/tmp/blank//home/stormnode/store/html/new/

You can also use the parallel RM command to delete

Parallel RM-RF dir/{}::: ' ls-f dir/'


Linux Fast Delete a large number of small file methods when we want to delete tens of thousands of or hundreds of thousands of or even millions of of files in a Linux system, using RM-RF * is not very useful because it takes a long time to wait. In this case, we can use the Linux system command rsync to skillfully handle.     Rsync actually uses the principle of substitution, processing hundreds of thousands of files is also a second deletion. 1. rsync installation, some systems have the default installation of the command Ubuntu system: sudo apt-get install rsync fedora System: sudo yum install rsync other can source installation, to the following Web site download http:/ /rsync.samba.org

    2. Rsync provides some parameters related to deletion rsync--help | grep Delete      --del                                an alias for--delete-during      --delete           &N Bsp              delete extraneous files from destination dirs      --delete -before             receiver deletes before transfer, not during      --delet E-during             receiver deletes during transfer (default)      --delete -delay               find deletions during, delete after      --DELETE-A fter                receiver deletes after transfer, not during     &NBS p;--delete-excluded        also delete excluded files from destination dirs      --ignore-errors             Delete Even if there are I/O errors &n Bsp    --max-delete=num    don ' t delete more than NUM files where--delete-before recipient deletes operations before transmission  

3. Examples empty directories or files, as follows: 1, first set up an empty directory Mkdir/data/blank 2, with rsync Delete target directory rsync--delete-before-d-a-h-v--progress--stats/da ta/blank//var/edatacache/or rsync--delete-before-d/data/blank//var/edatacache/
So the/var/edatacache directory is quickly emptied. Option Description:
–delete-before recipient to delete before transmission
–progress Displays the transfer process during transmission
-a archive mode, which represents the transfer of files recursively and maintains all file attributes
-H Keep Hard connected files
-V Verbose output mode
–stats               Give some file transfer status-D             &NB Sp        transfer directories without recursing   3, can also be used to delete large files if we have a dozens of g or even hundreds g of file data under/root/, Now we're going to delete it. Create an empty file     Touch/root/empty II, clear/root/data files with rsync     rsync --delete-before-d--p Rogess--stats/root/empty/root/data     NOTE: When SRC and dest files are inconsistent in nature will be the error   when SRC and Dest properties are the file "F", It means emptying the contents of a file instead of deleting it   when the SRC and Dest properties are all directory "D", it means deleting all the files in the directory and making it empty

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.