How to monitor WGET download progress after closing SSH session

I have started downloading my ISO’s etc directly to my fileserver using wget. After I close the ssh session, how can I check back on the download process?

Scenario: I start the download, then shut down my computer. The next day I ssh into the server and want to see if the download is still active, complete or has been interupted.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

Go to download directory and type

tail -f wget-log

Method 3

After a bit of Googling, I found an answer with the discovery an app called Screen.

After installation on the server (sudo apt-get install screen), you SSH into the server and open a screen session on the server with screen -S SESSION_NAME (replacing SESSION_NAME with any name you like). Then you run WGET and once the download is running, exit the session with CTRL+a, then press d (to detatch from the session. You can run multiple sessions (with different names) at the same time.

After re-login at a later date, you can check on your processes by SSHing into the server and reopening the screen session on the server with screen -r SESSION_NAME (to reconnect to the session).

Once the session is finished with, kill it with CTRL+a, then press k (to kill the session).

It’s like having a virtual terminal within your virtual terminal.

Method 4

You can also use tmux (which is a bit like screen) but I think is easier to use.

sudo apt-get install tmux
tmux new -s <session-name>

then run you script in the session
press control + b + d to detach

when you want to get back the terminal simply do

tmux a

The advantage is that you can check back easily if anything has gone wrong but if you want to download lots of simultaneous files, maybe its easier to check the log


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x