Synchronization
與 Web 伺服器的目錄列表同步
有沒有一種簡單的方法可以通過 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
.
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.
與 rsync 類似,但使用zsync從 httpd 伺服器獲取。