Wget - try series of backup links
How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?
wget mirroring
add a comment |
How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?
wget mirroring
add a comment |
How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?
wget mirroring
How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?
wget mirroring
wget mirroring
asked Feb 11 at 15:00
Chris JeffersonChris Jefferson
1083
1083
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Try this:
#!/bin/sh
for site in www.example.com mirror1.example.com another.mirror.com
do
wget --timeout=60 --continue $site/file.gz && break
done
The --continue switch allows you to pickup downloading where the last site left off.
Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.
add a comment |
Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:
$ wget --timeout=60 --tries=1 --continue --input-file <inputfile>
For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.
What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1404465%2fwget-try-series-of-backup-links%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this:
#!/bin/sh
for site in www.example.com mirror1.example.com another.mirror.com
do
wget --timeout=60 --continue $site/file.gz && break
done
The --continue switch allows you to pickup downloading where the last site left off.
Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.
add a comment |
Try this:
#!/bin/sh
for site in www.example.com mirror1.example.com another.mirror.com
do
wget --timeout=60 --continue $site/file.gz && break
done
The --continue switch allows you to pickup downloading where the last site left off.
Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.
add a comment |
Try this:
#!/bin/sh
for site in www.example.com mirror1.example.com another.mirror.com
do
wget --timeout=60 --continue $site/file.gz && break
done
The --continue switch allows you to pickup downloading where the last site left off.
Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.
Try this:
#!/bin/sh
for site in www.example.com mirror1.example.com another.mirror.com
do
wget --timeout=60 --continue $site/file.gz && break
done
The --continue switch allows you to pickup downloading where the last site left off.
Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.
answered Feb 11 at 15:31
Ken JacksonKen Jackson
22112
22112
add a comment |
add a comment |
Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:
$ wget --timeout=60 --tries=1 --continue --input-file <inputfile>
For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.
What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.
add a comment |
Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:
$ wget --timeout=60 --tries=1 --continue --input-file <inputfile>
For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.
What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.
add a comment |
Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:
$ wget --timeout=60 --tries=1 --continue --input-file <inputfile>
For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.
What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.
Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:
$ wget --timeout=60 --tries=1 --continue --input-file <inputfile>
For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.
What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.
answered Feb 11 at 18:17
darnirdarnir
613518
613518
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1404465%2fwget-try-series-of-backup-links%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown