将一个文件从一个Web服务器同步到另一个Web服务器

时间:2013-07-17 08:09:36

标签: php linux shell command-line-interface

我想编写一个php脚本,将一个特定文件从一个Web服务器(linux)复制到另一个(linux)。

2 个答案:

答案 0 :(得分:0)

您可以像这样在PHP中执行rsync。

exec('rsync -ruva --progress /local/file.png user@remote.server.com:/tmp/file.png');

检查here以获取有关如何设置无密码ssh以运行rsync的信息。

答案 1 :(得分:0)

在php中你可以使用 fopen fgets (另见http://php.net/manual/de/features.remote-files.php