【问题标题】:Could rsync wait file created and then copy it in the same time可以创建rsync等待文件,然后同时复制它
【发布时间】:2019-04-18 23:46:15
【问题描述】:

我想使用“rsync”将文件从A复制到B,但是文件现在在A中不存在。我在B上运行“rsync”命令,我可以让“rsync”等到文件完成在A中创建,同时复制?

【问题讨论】:

    标签: rsync


    【解决方案1】:

    假设我们从在 hostB 上运行的命令开始,例如

    hostB$ rsync hostA:remotepath localpath
    

    如果 hostA 有一个普通的 shell,我们可以通过调整它通常在 hostA 上运行的辅助命令让 rsync 等到文件存在。根据环境,这样的事情可能会起作用:

    hostB$ rsync --rsync-path='
        while [ ! -f remotefile ]; do sleep 1; done;
        sleep 5;
        rsync' hostA:remotepath localpath
    
    • while 循环繁忙等待 remotefile 可用
    • 然后sleep 5 让内容稳定几秒钟
    • rsync 是普通的远程命令
      • 必须最后来
      • 不得以换行符、分号或注释结尾

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-23
      • 1970-01-01
      • 2016-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多