How to run wget in background and resume download?
This article provides a quick overview of how to use the
wget command-line utility to download files continuously in
the background and resume interrupted transfers. You will learn the
specific flags required for these operations, how to combine them for
efficiency, and how to monitor your background download tasks.
The Background Flag:
-b / --background
To force wget to download a file in the background
immediately after starting, use the -b (or
--background) flag.
When you use this flag, the command immediately relinquishes control of the terminal, allowing you to continue working while the download proceeds in the background.
wget -b http://example.com/largefile.zipNote: If you do not specify an output file for the logs,
wgetautomatically redirects its progress and logging output to a file namedwget-login the current directory.
The Resume Flag: -c
/ --continue
To continue downloading a partially downloaded file, use the
-c (or
--continue) flag.
This is incredibly useful if your network connection drops midway
through a large download. Instead of restarting from scratch,
wget looks at the local file size and asks the server to
send the remaining pieces.
wget -c http://example.com/largefile.zipCombining Background and Resume Flags
For large files, it is common practice to combine both flags. This ensures that the download runs out of sight and will safely append data to your existing partial file if you are restarting a previously failed attempt.
wget -bc http://example.com/largefile.zipMonitoring Background Downloads
Because background downloads do not print directly to your terminal screen, you can check on their progress by viewing the tail end of the automatically generated log file. Use the following command to watch the download progress in real-time:
tail -f wget-log