Quickly delete a large number of files in linux

Source: Internet
Author: User


In linux, you can quickly delete a large number of files. If you want to delete a large number of files in linux, such as emails such as/var/spool/clientmqueue, for example, the nginx cache of/usr/local/nginx/proxy_temp may be poor. Rsync provides deletion-related parameters www.2cto.com rsync -- help | grep delete -- del an alias for -- delete-during -- delete files that don't exist on the sending side -- delete -before transferer deletes before transfer (default) -- delete-during receiver deletes during transfer, not before -- delete-after deleting er deletes after transfer, not before -- delete-excluded also delete excluded files on the processing side -- ignore-errors delete even if there are I/O errors -- max-delete = NUM don't delete more than NUM files. The -- delete-before receiver deletes the object before transmission.
It can be used to clear directories or files as follows: 1. Create an empty directory mkdir/data/blank 2. Use rsync to delete the target directory rsync -- delete-before-d/data/blank // var/spool/clientmqueue /. the directory will soon be cleared. If you have some very large files to delete, for example, nohup. out files that are updated in real time are usually dozens of GB and hundreds of GB. You can also use www.2cto.com to use rsync to clear large files, and relatively high efficiency 1. Create an empty file touch/data/blank.txt 2. Use rsync to clear the file rsync-a -- delete-before -- progress -- stats/root/blank.txt/root/nohup. out building file list... 1 file to consider blank.txt 0 100% 0.00kB/s 0:00:00 (xfer #1, to-check = 0/1) Number of files: 1 Number of files transferred: 1 Total file size: 0 bytes Total transferred file size: 0 bytes Literal data: 0 bytes Matched data: 0 bytes File list size: 27 File list generation time: 0.006 seconds File list transfer time: 0.000 seconds Total bytes sent: 73 Total bytes encoded ed: 31 www.2cto.com sent 73 bytes encoded ed 31 bytes 208.00 bytes/sec total size is 0 speedup is 0.00 tips: when the properties of SRC and DEST files are inconsistent, an error will be reported. When both SRC and DEST files are of the [f] nature, it means clearing the file content rather than deleting the file. When SRC and DEST are both directories [d], it means deleting all the files in the directory and making it empty. The most important thing is that, its processing speed is quite fast. The core of Processing Several GB files in seconds is: rsync actually uses the replacement principle by Zhang Hui.

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.