在營運的工作中、有時我們需要去刪除大檔案、或者 N (N 取正無窮喲~~)多小檔案
那麼、rm 次奧咯、
這裡、Rocky 介紹 Linux 史上最可愛、最溫柔、最成熟、最善良、最.....槽糕、找不到形容詞、囧
那便是 rsync 的另外一種用法
① 文法:
# rsync --delete-before -avH --progress --stats DEST SRC
解釋:
當SRC和DEST性質都為檔案【f】時,意思是清空檔案內容而不是刪除檔案
當SRC和DEST性質都為目錄【d】時,意思是刪除該目錄下的所有檔案,使其變為空白目錄
PS:其實該命令頂好記的哦、av -_-#、H$_$、男人很少不懂的、騷年、此時你的硬碟都有誰來著、、
② 原理:
rsync實際上用的就是替換原理
③ 優點:
處理速度相當快,處理幾個G的檔案也就是秒級的事、比rm要快很多倍
④ 缺點:
對磁碟io的佔用較高、業務高峰或要暫避
⑤ 測試:
[root@localhost log]# ls
rhel-server-5.8-i386-dvd.iso
[root@localhost log]# pwd
/tmp/test/log
[root@localhost ~]# mkdir empty
[root@localhost ~]# rsync --delete-before -avH --progress --stats /root/empty/ /tmp/test/log/
building file list ...
1 file to consider
deleting rhel-server-5.8-i386-dvd.iso
./
Number of files: 1
Number of files transferred: 0
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 19
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 29
Total bytes received: 15
sent 29 bytes received 15 bytes 6.77 bytes/sec
total size is 0 speedup is 0.00
推薦閱讀:
rsync同步完整配置
利用rsync工具進行同步Windows和Linux機器之間的檔案
Rsync+inotify 組合使用同步方案
Rsync和inotify檔案即時備份配置
CentOS 5.5下Rsync提示與許可權問題解讀