douxiong3234 2014-03-17 17:27
浏览 19
已采纳

寻找一种自动检查文件更新的方法,如果有更改,请下载到我们服务器上的目录

We will be implementing a new template for our web site. The template actually lives on another server. I would like to schedule a script to run nightly, to check if the remote page has been updated since the last download, and if so, download the file to a directory on our server. I can use either perl or php.

  • 写回答

1条回答 默认 最新

  • donk68254 2014-03-17 17:33
    关注

    In nothing but PHP, you could use something like similar_text() (or levenshtein() ):

    if(similar_text( // line breaks for clarity.
        file_get_contents("/path/to/local.tpl"), 
        file_get_contents("http://remote.com/remote.tpl") < 90
     ) {// thus, if the similarity between the two files is less than 90%, 
         file_put_contents("/path/to/local.tpl", "http://remote.com/remote.tpl"); 
     }// download and save the remote template.
    

    Or, if you wanted to use rsync - just go for system() or exec() and pass a script as the argument.

    to make it run nightly, you just add it to the crontab:

    crontab -e
    

    add:

    59 23 * * * /path/to/bash-or-php.script
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因