If you run wget and close the terminal or terminate your ssh session , it will terminate the wget process too. You need to run wget and keep it running even after the session is closed.
For that purpose there are many tools.
wget -bqc http://path-to-url/linux.iso
You will see a PID on screen:
Continuing in background, pid 12345.
Where,
-b : Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log.
-q : Turn off Wget’s output aka save disk space.
-c : Resume broken download i.e. continue getting a partially-downloaded file. This is useful when you want to finish up a download started by a previous instance of Wget, or by another program.
The nohup command
You can also use the nohup command to execute commands after you exit from a shell prompt. The syntax is:
$ nohup wget -qc http://path-to-url/linux.iso &
## exit from shell or close the terminal ##
$ exit
The disown bash command
Another option is to use the disown command as follows:
$ wget -qc http://path-to-url/linux.iso &
[1] 10685
$ disown wget
$ ps
PID TTY TIME CMD
10685 pts/0 00:00:00 wget
10687 pts/0 00:00:00 bash
10708 pts/0 00:00:00 ps
$ logout
The screen command
You can also use the screen command for this purpose.
echo 'wget ...' | at 'now + 1 minute'
(on systems which runatd
– some systemd-based ones don't do that anymore by default). In this way, there is no connection whatever between the download and the calling shell, since the download is started in one minute by the timed execution daemon. – Ulrich Schwarz Dec 29 '15 at 17:50ps aux | grep wget | grep -v grep
shows active wget processes. As for a way to check the progress percentage, if you start without-q
and you usednohup
then the progress will be printing in thenohup.out
file. – Captain Man Jan 23 '20 at 17:14wget -b
(without usingnohup
) keep it running even if the session is closed? I'm having trouble following. – Captain Man Jan 23 '20 at 17:16