
有沒有簡單的方法可以透過 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 伺服器取得。