Linux system will generate many useless small files after a long time of use. If you need to waste a lot of time to delete one by one, then there is a good way to quickly delete these small files. What? This needs to be handled using the rsync command.
1. rsync installed, some of the default command
Ubuntu system installed: sudo apt-get install rsync
Fedora system: sudo yum install rsync < Br>
2. rsync provides some parameters related to deletion
rsync --help |
Grep delete
--del an alias for --delete-during
--delete delete extraneous files from destination dirs
--delete-before receiver deletes before transfer, Not during
--delete-during receiver deletes during transfer (default)
--delete-delay find deletions during, delete after
--delete-after receiver deletes After transfer, not during
--delete-excluded also delete excluded files from destination dirs
--ignore-errors delete even if there are I/O errors
- -max-delete=NUM don‘t delete more than NUM files
where --delete-before the recipient deletes before the transfer
3. Example
Empty Directory or file, as follows:
First, create an empty directory
mkdir /data/blank
Second, use rsync to delete the target directory
rsync --delete-before -d -a -H -v --progress --stats /data/blank//var/edatacache/
or
rsync --delete-before -d /data/blank//var/edatacache/
This way the /var/edatacache directory is quickly emptied.
Option Description:
–delete-before Receiver deletes before transfer
–progress shows transfer process during transfer
- a Archive mode, which means that files are recursively transferred, and all file attributes are kept
-H files that are hard-wired
-v detailed output mode
–stats The transfer status of some files
-d transfer directories without recursing
Third, it can also be used to delete large files
If we have a few under /root/Ten G or even hundreds of G file data, now we want to delete it
1), create an empty file
touch /root/empty
2), use rsync Empty /root/data file
rsync --delete-before -d --progess --stats /root/empty /root/data
Note:
When SRC Will be reported when the nature of the DEST file is inconsistent
When the properties of SRC and DEST are both file [f], it means to clear the contents of the file instead of deleting it.
When the properties of SRC and DEST are both directory [d], it means to delete all the files in the directory, making it empty.
The above is the batch deletion of Linux using the rsync command. The method of small files is introduced. After using the rsync command, even hundreds of thousands of small files can be deleted quickly, saving you valuable time.
Linux users have a certain understanding of logical volumes, but many users still do not know how to
When CentOS installs vnc, it prompts that Could not start Xvnc error, causing the installation to fa
Markdowns syntax is widely used because it is easy to learn, so to use Markdown, it
Linux command, stty command is mainly used to print or modify the terminal settings, plus various pa
Linux uses the sed command to add a string method
Detailed method of configuring CentOS devices using Quagga software
How to detect when Linux system is invaded?
Linux uses GRUB to add kernel parameters
What is the command to specify the line in the Linux view file?
Linux refuses foreign IP access steps
How does the Linux system send mail?
Linux vim comment color can't see how to change?
Linux prompts [root@localhost ~]# iptraf when executing commands?
How to handle Too many open files under Linux?
Win8.1 Update new features large collection
How to use the "device" super button that slides out on the right side of the Win8 system
Simple command to easily close ipv6 tunnel in windows7
How to unlock sleep wakeup password in Win10
After the Win10 upgrade, the new RecoveryImage folder can be deleted.
Freelaunchbar installed in win7 found that can not find how to do
Trial Discovery - Four Reasons to Like Windows 7
Excel attachment can not open how to do
What should I do if the Win10 system uses an abnormal sound?