Skip to content

Instantly share code, notes, and snippets.

@juji
Last active July 10, 2024 13:16
Show Gist options
  • Save juji/f0f1c7283170f94438649aa3f72b6525 to your computer and use it in GitHub Desktop.
Save juji/f0f1c7283170f94438649aa3f72b6525 to your computer and use it in GitHub Desktop.
Wget Download File
#!/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