有没有一种简单的方法可以通过 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 服务器获取。