How to know if file is already finished downloading in linux command line?
If you're downloading a large file in linux via command line, is there a command to know if it's already completed? Currently I am only checking if the file size is the same as the expected file size but what if you don't know the expected file size? Currently ls shows the exact file name (i.e., file.zip) instead of something like file.zip.temp or something even if the file is currently downloading.
linux command-line debian wget
add a comment |
If you're downloading a large file in linux via command line, is there a command to know if it's already completed? Currently I am only checking if the file size is the same as the expected file size but what if you don't know the expected file size? Currently ls shows the exact file name (i.e., file.zip) instead of something like file.zip.temp or something even if the file is currently downloading.
linux command-line debian wget
Couldn't you just check whetherwgetis still running? (ps -ef | grep wget | grep -v grepor similar)
– slhck
Oct 21 '12 at 13:06
@slhck looks like that ninja code will do the job
– IMB
Oct 21 '12 at 13:21
You can also useiftopcommand that will show you active connection and the volume of network traffic. If you have a single download file per destination IP, you will be able to see when the transfer finishes.
– mnmnc
Aug 11 '15 at 10:32
add a comment |
If you're downloading a large file in linux via command line, is there a command to know if it's already completed? Currently I am only checking if the file size is the same as the expected file size but what if you don't know the expected file size? Currently ls shows the exact file name (i.e., file.zip) instead of something like file.zip.temp or something even if the file is currently downloading.
linux command-line debian wget
If you're downloading a large file in linux via command line, is there a command to know if it's already completed? Currently I am only checking if the file size is the same as the expected file size but what if you don't know the expected file size? Currently ls shows the exact file name (i.e., file.zip) instead of something like file.zip.temp or something even if the file is currently downloading.
linux command-line debian wget
linux command-line debian wget
asked Oct 21 '12 at 13:00
IMBIMB
2,464185991
2,464185991
Couldn't you just check whetherwgetis still running? (ps -ef | grep wget | grep -v grepor similar)
– slhck
Oct 21 '12 at 13:06
@slhck looks like that ninja code will do the job
– IMB
Oct 21 '12 at 13:21
You can also useiftopcommand that will show you active connection and the volume of network traffic. If you have a single download file per destination IP, you will be able to see when the transfer finishes.
– mnmnc
Aug 11 '15 at 10:32
add a comment |
Couldn't you just check whetherwgetis still running? (ps -ef | grep wget | grep -v grepor similar)
– slhck
Oct 21 '12 at 13:06
@slhck looks like that ninja code will do the job
– IMB
Oct 21 '12 at 13:21
You can also useiftopcommand that will show you active connection and the volume of network traffic. If you have a single download file per destination IP, you will be able to see when the transfer finishes.
– mnmnc
Aug 11 '15 at 10:32
Couldn't you just check whether
wget is still running? (ps -ef | grep wget | grep -v grep or similar)– slhck
Oct 21 '12 at 13:06
Couldn't you just check whether
wget is still running? (ps -ef | grep wget | grep -v grep or similar)– slhck
Oct 21 '12 at 13:06
@slhck looks like that ninja code will do the job
– IMB
Oct 21 '12 at 13:21
@slhck looks like that ninja code will do the job
– IMB
Oct 21 '12 at 13:21
You can also use
iftop command that will show you active connection and the volume of network traffic. If you have a single download file per destination IP, you will be able to see when the transfer finishes.– mnmnc
Aug 11 '15 at 10:32
You can also use
iftop command that will show you active connection and the volume of network traffic. If you have a single download file per destination IP, you will be able to see when the transfer finishes.– mnmnc
Aug 11 '15 at 10:32
add a comment |
6 Answers
6
active
oldest
votes
If you're downloading with wget, you can simply check if the instance is still running:
ps -ef | grep wget | grep -v grep
Also, you could check whether the file is still opened by wget. Obviously, replace the path here.
lsof /path/to/downloaded/file
add a comment |
If you do not need to execute wget in background, do not do it, it will only lead to complications.
I advocate against solutions like checking ps -C wget or pidof wget (shorter, perhaps non-POSIX, equivalents to ps -ef | grep wget | grep -v grep), since they will consider any wget and not only the one you are interested in, which might be an unassumable assumption if your machine does not only do one task.
If you are inside a script, you can wget & WGETPID=$! and then check that PID. Or you could simply wait, which would wait for your background processes to finish.
It might be important to do something in order to distinguish between a successful and unsuccessful download. if wget ... ; then touch wget_ok ; else touch wget_error ; fi
add a comment |
What if you are running more than one wget command?
If you need to accommodate for this scenario, then you could do a few different things:
- You could pipe the progress to a file with a known name and check that.
- You could force the idea you had in your question, download to a temporary file, then in a a second command rename it.
You could just write a token after the process is completed, i.e.
wget 'file'; touch file.is.done
add a comment |
The lsofapproach suggested by slhck is probably the best way. If you want to use the other suggestions involving creating a file once the download is complete, use && instead of ; so that a report is generated only if the download exits correctly:
wget file && touch file.is.done
add a comment |
I'd like rather sound signal, so if i start a long operation (not only wget but any time resourse consuming) that i don't want watch instantaneously i use something like
`LONG_COMMAND && SOUND_OK || SOUND_ERROR`
so even if i need to know immediately when it finishes i'll also be able to do something else the same time without interrupting myself time to time for the checking, i just can hear result (of SOUND_OK if first command exit status is 0 and SOUND_ERROR in other case) and check it only once when it finishes. You can even continue current activity if only you need to know is that your task finished. LONG_COMMAND could be wget, and as SOUND_OK i prefer echo -e "a" >/dev/console but you can use command to play any audio sample.
As long as wget can produce several different exit codes, one can use them to determine the alarm command in "bios-style" as follows
wget URL;
CODE=$?;
beep;
[ $CODE -gt 0 ] && while true; do
for peek in `seq 1 $CODE`; do
beep; sleep 1;done
sleep 3; done
add a comment |
you could start wget with -o dl.log option i.e. to define a log file which you can periodically check to see if you'll see (using regular expression) this line.
12:59:48 (126.32 MB/s) - `/path/to/downloaded/file/some_file.zip' saved [95235097/95235097]
actually, you can use "tail dl.log" to get only the last few lines instead of reading the whole thing.
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%2f490601%2fhow-to-know-if-file-is-already-finished-downloading-in-linux-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you're downloading with wget, you can simply check if the instance is still running:
ps -ef | grep wget | grep -v grep
Also, you could check whether the file is still opened by wget. Obviously, replace the path here.
lsof /path/to/downloaded/file
add a comment |
If you're downloading with wget, you can simply check if the instance is still running:
ps -ef | grep wget | grep -v grep
Also, you could check whether the file is still opened by wget. Obviously, replace the path here.
lsof /path/to/downloaded/file
add a comment |
If you're downloading with wget, you can simply check if the instance is still running:
ps -ef | grep wget | grep -v grep
Also, you could check whether the file is still opened by wget. Obviously, replace the path here.
lsof /path/to/downloaded/file
If you're downloading with wget, you can simply check if the instance is still running:
ps -ef | grep wget | grep -v grep
Also, you could check whether the file is still opened by wget. Obviously, replace the path here.
lsof /path/to/downloaded/file
answered Oct 21 '12 at 13:38
slhckslhck
160k47444466
160k47444466
add a comment |
add a comment |
If you do not need to execute wget in background, do not do it, it will only lead to complications.
I advocate against solutions like checking ps -C wget or pidof wget (shorter, perhaps non-POSIX, equivalents to ps -ef | grep wget | grep -v grep), since they will consider any wget and not only the one you are interested in, which might be an unassumable assumption if your machine does not only do one task.
If you are inside a script, you can wget & WGETPID=$! and then check that PID. Or you could simply wait, which would wait for your background processes to finish.
It might be important to do something in order to distinguish between a successful and unsuccessful download. if wget ... ; then touch wget_ok ; else touch wget_error ; fi
add a comment |
If you do not need to execute wget in background, do not do it, it will only lead to complications.
I advocate against solutions like checking ps -C wget or pidof wget (shorter, perhaps non-POSIX, equivalents to ps -ef | grep wget | grep -v grep), since they will consider any wget and not only the one you are interested in, which might be an unassumable assumption if your machine does not only do one task.
If you are inside a script, you can wget & WGETPID=$! and then check that PID. Or you could simply wait, which would wait for your background processes to finish.
It might be important to do something in order to distinguish between a successful and unsuccessful download. if wget ... ; then touch wget_ok ; else touch wget_error ; fi
add a comment |
If you do not need to execute wget in background, do not do it, it will only lead to complications.
I advocate against solutions like checking ps -C wget or pidof wget (shorter, perhaps non-POSIX, equivalents to ps -ef | grep wget | grep -v grep), since they will consider any wget and not only the one you are interested in, which might be an unassumable assumption if your machine does not only do one task.
If you are inside a script, you can wget & WGETPID=$! and then check that PID. Or you could simply wait, which would wait for your background processes to finish.
It might be important to do something in order to distinguish between a successful and unsuccessful download. if wget ... ; then touch wget_ok ; else touch wget_error ; fi
If you do not need to execute wget in background, do not do it, it will only lead to complications.
I advocate against solutions like checking ps -C wget or pidof wget (shorter, perhaps non-POSIX, equivalents to ps -ef | grep wget | grep -v grep), since they will consider any wget and not only the one you are interested in, which might be an unassumable assumption if your machine does not only do one task.
If you are inside a script, you can wget & WGETPID=$! and then check that PID. Or you could simply wait, which would wait for your background processes to finish.
It might be important to do something in order to distinguish between a successful and unsuccessful download. if wget ... ; then touch wget_ok ; else touch wget_error ; fi
answered Oct 22 '12 at 8:58
Raúl Salinas-MonteagudoRaúl Salinas-Monteagudo
970610
970610
add a comment |
add a comment |
What if you are running more than one wget command?
If you need to accommodate for this scenario, then you could do a few different things:
- You could pipe the progress to a file with a known name and check that.
- You could force the idea you had in your question, download to a temporary file, then in a a second command rename it.
You could just write a token after the process is completed, i.e.
wget 'file'; touch file.is.done
add a comment |
What if you are running more than one wget command?
If you need to accommodate for this scenario, then you could do a few different things:
- You could pipe the progress to a file with a known name and check that.
- You could force the idea you had in your question, download to a temporary file, then in a a second command rename it.
You could just write a token after the process is completed, i.e.
wget 'file'; touch file.is.done
add a comment |
What if you are running more than one wget command?
If you need to accommodate for this scenario, then you could do a few different things:
- You could pipe the progress to a file with a known name and check that.
- You could force the idea you had in your question, download to a temporary file, then in a a second command rename it.
You could just write a token after the process is completed, i.e.
wget 'file'; touch file.is.done
What if you are running more than one wget command?
If you need to accommodate for this scenario, then you could do a few different things:
- You could pipe the progress to a file with a known name and check that.
- You could force the idea you had in your question, download to a temporary file, then in a a second command rename it.
You could just write a token after the process is completed, i.e.
wget 'file'; touch file.is.done
edited Oct 21 '12 at 14:09
slhck
160k47444466
160k47444466
answered Oct 21 '12 at 13:56
NickNick
1861111
1861111
add a comment |
add a comment |
The lsofapproach suggested by slhck is probably the best way. If you want to use the other suggestions involving creating a file once the download is complete, use && instead of ; so that a report is generated only if the download exits correctly:
wget file && touch file.is.done
add a comment |
The lsofapproach suggested by slhck is probably the best way. If you want to use the other suggestions involving creating a file once the download is complete, use && instead of ; so that a report is generated only if the download exits correctly:
wget file && touch file.is.done
add a comment |
The lsofapproach suggested by slhck is probably the best way. If you want to use the other suggestions involving creating a file once the download is complete, use && instead of ; so that a report is generated only if the download exits correctly:
wget file && touch file.is.done
The lsofapproach suggested by slhck is probably the best way. If you want to use the other suggestions involving creating a file once the download is complete, use && instead of ; so that a report is generated only if the download exits correctly:
wget file && touch file.is.done
edited Mar 20 '17 at 10:16
Community♦
1
1
answered Oct 24 '12 at 12:35
terdonterdon
41.3k887136
41.3k887136
add a comment |
add a comment |
I'd like rather sound signal, so if i start a long operation (not only wget but any time resourse consuming) that i don't want watch instantaneously i use something like
`LONG_COMMAND && SOUND_OK || SOUND_ERROR`
so even if i need to know immediately when it finishes i'll also be able to do something else the same time without interrupting myself time to time for the checking, i just can hear result (of SOUND_OK if first command exit status is 0 and SOUND_ERROR in other case) and check it only once when it finishes. You can even continue current activity if only you need to know is that your task finished. LONG_COMMAND could be wget, and as SOUND_OK i prefer echo -e "a" >/dev/console but you can use command to play any audio sample.
As long as wget can produce several different exit codes, one can use them to determine the alarm command in "bios-style" as follows
wget URL;
CODE=$?;
beep;
[ $CODE -gt 0 ] && while true; do
for peek in `seq 1 $CODE`; do
beep; sleep 1;done
sleep 3; done
add a comment |
I'd like rather sound signal, so if i start a long operation (not only wget but any time resourse consuming) that i don't want watch instantaneously i use something like
`LONG_COMMAND && SOUND_OK || SOUND_ERROR`
so even if i need to know immediately when it finishes i'll also be able to do something else the same time without interrupting myself time to time for the checking, i just can hear result (of SOUND_OK if first command exit status is 0 and SOUND_ERROR in other case) and check it only once when it finishes. You can even continue current activity if only you need to know is that your task finished. LONG_COMMAND could be wget, and as SOUND_OK i prefer echo -e "a" >/dev/console but you can use command to play any audio sample.
As long as wget can produce several different exit codes, one can use them to determine the alarm command in "bios-style" as follows
wget URL;
CODE=$?;
beep;
[ $CODE -gt 0 ] && while true; do
for peek in `seq 1 $CODE`; do
beep; sleep 1;done
sleep 3; done
add a comment |
I'd like rather sound signal, so if i start a long operation (not only wget but any time resourse consuming) that i don't want watch instantaneously i use something like
`LONG_COMMAND && SOUND_OK || SOUND_ERROR`
so even if i need to know immediately when it finishes i'll also be able to do something else the same time without interrupting myself time to time for the checking, i just can hear result (of SOUND_OK if first command exit status is 0 and SOUND_ERROR in other case) and check it only once when it finishes. You can even continue current activity if only you need to know is that your task finished. LONG_COMMAND could be wget, and as SOUND_OK i prefer echo -e "a" >/dev/console but you can use command to play any audio sample.
As long as wget can produce several different exit codes, one can use them to determine the alarm command in "bios-style" as follows
wget URL;
CODE=$?;
beep;
[ $CODE -gt 0 ] && while true; do
for peek in `seq 1 $CODE`; do
beep; sleep 1;done
sleep 3; done
I'd like rather sound signal, so if i start a long operation (not only wget but any time resourse consuming) that i don't want watch instantaneously i use something like
`LONG_COMMAND && SOUND_OK || SOUND_ERROR`
so even if i need to know immediately when it finishes i'll also be able to do something else the same time without interrupting myself time to time for the checking, i just can hear result (of SOUND_OK if first command exit status is 0 and SOUND_ERROR in other case) and check it only once when it finishes. You can even continue current activity if only you need to know is that your task finished. LONG_COMMAND could be wget, and as SOUND_OK i prefer echo -e "a" >/dev/console but you can use command to play any audio sample.
As long as wget can produce several different exit codes, one can use them to determine the alarm command in "bios-style" as follows
wget URL;
CODE=$?;
beep;
[ $CODE -gt 0 ] && while true; do
for peek in `seq 1 $CODE`; do
beep; sleep 1;done
sleep 3; done
edited Oct 9 '14 at 1:08
answered Oct 9 '14 at 0:10
Leben GlebenLeben Gleben
555
555
add a comment |
add a comment |
you could start wget with -o dl.log option i.e. to define a log file which you can periodically check to see if you'll see (using regular expression) this line.
12:59:48 (126.32 MB/s) - `/path/to/downloaded/file/some_file.zip' saved [95235097/95235097]
actually, you can use "tail dl.log" to get only the last few lines instead of reading the whole thing.
add a comment |
you could start wget with -o dl.log option i.e. to define a log file which you can periodically check to see if you'll see (using regular expression) this line.
12:59:48 (126.32 MB/s) - `/path/to/downloaded/file/some_file.zip' saved [95235097/95235097]
actually, you can use "tail dl.log" to get only the last few lines instead of reading the whole thing.
add a comment |
you could start wget with -o dl.log option i.e. to define a log file which you can periodically check to see if you'll see (using regular expression) this line.
12:59:48 (126.32 MB/s) - `/path/to/downloaded/file/some_file.zip' saved [95235097/95235097]
actually, you can use "tail dl.log" to get only the last few lines instead of reading the whole thing.
you could start wget with -o dl.log option i.e. to define a log file which you can periodically check to see if you'll see (using regular expression) this line.
12:59:48 (126.32 MB/s) - `/path/to/downloaded/file/some_file.zip' saved [95235097/95235097]
actually, you can use "tail dl.log" to get only the last few lines instead of reading the whole thing.
answered Aug 11 '15 at 10:05
Svetoslav MarinovSvetoslav Marinov
1012
1012
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%2f490601%2fhow-to-know-if-file-is-already-finished-downloading-in-linux-command-line%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
Couldn't you just check whether
wgetis still running? (ps -ef | grep wget | grep -v grepor similar)– slhck
Oct 21 '12 at 13:06
@slhck looks like that ninja code will do the job
– IMB
Oct 21 '12 at 13:21
You can also use
iftopcommand that will show you active connection and the volume of network traffic. If you have a single download file per destination IP, you will be able to see when the transfer finishes.– mnmnc
Aug 11 '15 at 10:32