Skip to content

Instantly share code, notes, and snippets.

@catichenor
Created June 12, 2020 23:39
Show Gist options
  • Save catichenor/c65bb9e727b90b283f2df293afb7cf27 to your computer and use it in GitHub Desktop.
Save catichenor/c65bb9e727b90b283f2df293afb7cf27 to your computer and use it in GitHub Desktop.
Download a file over HTTP, automatically resume the download if the exit status isn't zero, and restart the download when it stalls.
#!/usr/bin/env bash
# Taken from https://ilovesymposia.com/2013/04/11/automatically-resume-interrupted-downloads-in-osx-with-curl/ and https://ec.haxx.se/usingcurl/usingcurl-timeouts
export ec=18; while [ $ec -ne 0 ]; do /usr/bin/curl --speed-time 15 --speed-limit 1000 -O -C - "http://somedomain.com/path/to/some_huge_file.txt"; export ec=$?; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment