How to Display WGET Status When Running with -b flag in Background?

While it’s possible to run wget in the background using an ampersand after issuing a command, it’s generally more useful to issue the command with the -b flag. For instance, let’s assume you wanted to download a Debian CD install image. You could do so with wget -b https://cdimage.debian.org/mirror/cdimage/archive/8.7.1/i386/list-cd/debian-8.7.1-i386-CD-1.list.gz, which would then immediately tell you that the process is continuing in the background. It would additionally give you a processor identification number that indicates which background process wget runs in.

Even though background-running wget processes provide no other information in this respect, that doesn’t mean you can’t display the status if you’d like. You can easily open the wget log file in a text editor. Programmers designed this process to work with large big iron servers, which means that you won’t have any options to make things pretty. Then again, you won’t have to go through more than a single extremely basic step to get the information you’re looking for. All it involves is opening a single file.

Displaying wget Background Downloading Status

Let’s assume you used wget -b followed by an address to a resource that you’re downloading. While we used that Debian LXDE install ISO, you could theoretically use nearly any resource online. The wget program’s process can’t be brought to the foreground the way you can with processes you used an ampersand to send to the background. In fact, if you run the jobs command immediately after starting wget in this way, you’ll find that there are no background processes registered with the bash shell, though you could use kill followed by the process ID if you wanted to abruptly stop your wget process. This wouldn’t download the file correctly, though.

You could click on the downloaded file and watch the file size grow in a graphical file manager. However, wget creates log files by default that it constantly writes out. It names these wget-log and then starts to use numbers if you’re downloading more than one file in this manner to the same directory or if you left old log files in it. This prevents wget from overwriting its own log files. You can double-click these files in a graphical file manager to open them up, or you could use the less or more commands from the CLI prompt to load them up. Current download status is always on the last line of the file.

Keep in mind that wget constantly writes to these files, meaning that you’ll need to repeatedly open them in a graphical file manager or repeatedly issue the same cat, less or more command in the CLI prompt to view any relevant changes. You could use -o followed by a file name when you start the wget command to specify a custom log file, but few users ever do this. You might also use the -a flag followed by the name of a log file to instead append messages to a file you already have. Don’t try to run two background wget processes appending to the same log, however, since this might just give you a file loaded with gibberish. The wget software would attempt to write line after line from both processes, leading to interspaced information that would be hard to read.

Any of these flags work with the other flags that you might use when working with wget, but keep in mind that wget always defaults to the -v flag. This flag enables verbose output, which is what most users are used to. Combining the -b flag and the -q flag for quiet output can keep you in the dark in regards to what wget is doing at any given time. Technically, you could combine the -b and -d flags, but all this does is enable debug-level output that tells you more about what the software is doing behind the scenes. This additional output is normally only useful for those working on editing wget’s source code, and the vast majority of users can avoid it totally. Even programmers who are working on download scripts shouldn’t need this information, and in most cases, it will just cause unnecessary clutter.

Remember that if you used wget in some other directory than ~/Downloads, then it will put your log files there too.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.