rsync Fast Delete small file method in Linux

Source: Internet
Author: User
Tags rsync

Rsync is a sync tool I just used it to do data synchronization operation did not want to do file deletion operation, but today saw an article can implement file deletion operation, below we take a look.

Use rsync to synchronize an empty directory. For the million-level file directory is the basic second Delete, enter the OK.

The steps are as follows:

1. Create an empty directory

Mkdir-p/tmp/rsync_blank

2, the establishment needs to clear the target directory

/data/ooxx

3, use rsync Sync Delete (Note the "/" Behind the directory), the overall efficiency will be a number of orders of magnitude.

Rsync–delete-before-a-h-v–progress–stats/tmp/rsync_blank//data/ooxx/

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 gives the transfer status of some files
Generally we do not need to show progress, use the following command to

Rsync–delete-before-a-h/tmp/rsync_blank//data/ooxx/

So the cache directory we want to delete will be emptied.

Tips

Error occurs when SRC and dest files are inconsistent in nature
When both SRC and Dest properties are file "F", it means emptying the contents of the file rather than deleting the file
When both SRC and Dest properties are directory "D", the meaning is to delete all files in the directory to make it empty
The most important thing is that it's handled fairly quickly, dealing with several G files, which is the second level.
The core content is that rsync actually uses the principle of substitution.

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.