传输后rsync删除发送端的文件 [英] rsync delete files on sending side after transfer

查看:100
本文介绍了传输后rsync删除发送端的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从远程机器下载大量数据.我希望在每次文件下载完成时删除远程计算机上的数据.

I want to download a large amount of data from a remote machine. I'd like the data to be erased on the remote machine everytime a file finishes downloading.

我该怎么做?rsync 是否有标志可以执行此操作?

How do I do that? Is there a flag for rsync to do this?

推荐答案

您需要将 --remove-source-files 选项传递给 rsync 命令.它告诉 rsync 从发送方删除作为传输一部分并已在接收方成功复制的文件(即非目录).不要将 --delete 选项传递给 rsync 命令,因为它会从目标目录中删除无关文件.使用 rsync 成功传输后删除源.

You need to pass the --remove-source-files option to the rsync command. It tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side. Do not pass the --delete option to rsync command as it delete extraneous files from destination directory. Delete source after successful transfer using rsync.

语法是:

rsync --remove-source-files -options /path/to/src/ /path/to/dest
rsync --remove-source-files -options /path/to/src/ computerB:/path/to/dest
rsync --remove-source-files -av /path/to/src/*.avi computerB:/path/to/dest

参考:http:///www.cyberciti.biz/faq/linux-unix-bsd-appleosx-rsync-delete-file-after-transfer/

这篇关于传输后rsync删除发送端的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆