Skip to content

Instantly share code, notes, and snippets.

@blacklee
Last active December 22, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blacklee/6461014 to your computer and use it in GitHub Desktop.
Save blacklee/6461014 to your computer and use it in GitHub Desktop.
远程下载zip文件。远程机器网速快但存储不够。适用于中国用户下载国外资源。
cd /path/to/dir && wget -w 30 -i url-list.txt
# run by crond, */5 * * * * bash /path/to/dir/test.sh > /dev/null
cd /path/to/dir
for i in `ls *.zip`; do
unzip -t $i > /dev/null
if [[ $? -eq 0 ]]; then
mv $i download_done/
fi
done
# run by crond, */5 * * * * bash /path/to/dir/download_and_test.sh > /dev/null
cd /path/to/dir
while(true)
do
scp usr@remote_server:/path/to/dir/download_done/*.zip .
for i in `ls *.zip`; do
unzip -t $i >/dev/null
if [[ $? -eq 0 ]]; then
mv $i transfer_succ/
ssh usr@remote_server "rm /path/to/dir/download_done/$i"
else
rm $i
fi
done
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment