• 把一个机器上1天内新增的文件用rsync传送到另外一台机器


    我的shell很菜,只好用shell和php结合来做


    1.查找新增的文件,构造rsync的参数,把结果写入到log中


    find /data/bmob/test/teststorage/data/ -mtime -2|awk '{FS="/"} {print "/data/bmob/test/teststorage/data/"$7"/"$8"/"$9" bmob116:/home/teststorage/data/"$7"/"$8"/"$9}'  >>readline.log

    2. 用php执行rsync命令


    <?php
    
     $F  = fopen("readline.log", "r");
     while ($x = fgets($F, 4096))
     {
      $str= "/usr/bin/rsync -vltzhaP -e ssh --delete -r --bwlimit=3072 $x ";
      echo $str;
      $output = shell_exec($str);
      echo $output;
     }
     fclose($F);

    [文章作者]曾健生

    [作者邮箱]h6k65@126.com

    [作者QQ]190678908

    [新浪微博] @newjueqi

    [博客]http://blog.csdn.net/newjueqi


    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    小程序生命周期
    async/await实现图片的串行、并行加载
    移动应用区别
    小程序组件
    secureCRT
    LInux
    java实现八大排序算法
    求出所有排列 去重全排列 回溯算法
    二分法基本思想
    异常
  • 原文地址:https://www.cnblogs.com/dingxiaoyue/p/4926765.html
Copyright © 2020-2023  润新知