Last active
July 10, 2024 13:16
-
-
Save juji/f0f1c7283170f94438649aa3f72b6525 to your computer and use it in GitHub Desktop.
Wget Download File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
startTime=$(date) | |
url="$1" | |
if [ "$url" = "" ]; then | |
echo "url can't be empty" | |
echo "usage: download url" | |
exit 1 | |
fi | |
echo "start" | |
keepWorking=1 | |
while [ "$keepWorking" -eq "1" ]; do | |
wget -c \ | |
--read-timeout=10 \ | |
--waitretry=5 \ | |
--random-wait \ | |
--retry-connrefused \ | |
"$url" | |
if [ "$?" -eq "0" ]; then | |
keepWorking=0 | |
echo "" | |
echo "DONE" | |
else | |
echo "" | |
echo "will keep downloading.." | |
echo "" | |
fi | |
sleep 5 | |
done | |
echo "start: $startTime" | |
echo "end: $(date)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment