![与 Web 服务器的目录列表同步](https://linux22.com/image/22481/%E4%B8%8E%20Web%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E7%9B%AE%E5%BD%95%E5%88%97%E8%A1%A8%E5%90%8C%E6%AD%A5.png)
有没有一种简单的方法可以通过 HTTP 使文件夹与目录列表保持同步?
编辑:
感谢 wget 的提示!我创建了一个 shell 脚本并将其添加为 cron 作业:
remote_dirs=( "http://example.com/" "…") # Add your remote HTTP directories here
local_dirs=( "~/examplecom" "…")
for (( i = 0 ; i < ${#local_dirs[@]} ; i++ )) do
cd "${local_dirs[$i]}"
wget -r -l1 --no-parent -A "*.pdf" -nd -nc ${remote_dirs[$i]}
done
# Explanation:
# -r to download recursively
# -l1 to include only one directory depth
# --no-parent to exclude parent directories
# -A "*.pdf" to accept only .pdf files
# -nd to prevent wget to create directories for everything
# -N to make wget to download only new files
编辑2:
如下所述,还可以使用--mirror
( -m
),它是 的简写-r -N
。
答案1
wget
是一个很棒的工具。
使用wget -m http://somesite.com/directory
-m
--mirror
Turn on options suitable for mirroring. This option turns on
recursion and time-stamping, sets infinite recursion depth and
keeps FTP directory listings. It is currently equivalent to
-r -N -l inf --no-remove-listing.
答案2
与 rsync 类似,但使用同步从 httpd 服务器获取。