What Happens When Wget Quota Is Exceeded?
This article provides a quick overview of how the GNU
wget utility behaves when a pre-configured download quota
is exceeded. When using the --quota limit,
wget monitors the cumulative size of downloaded files
during a single execution or session. Once this threshold is crossed,
the utility immediately terminates any further downloading to prevent
excessive bandwidth or storage consumption, though its behavior varies
slightly depending on whether it is downloading a single file or a list
of files.
Understanding the Wget Quota Mechanism
The --quota option in wget allows users to
specify a maximum byte limit for downloads, using suffixes like
k for kilobytes and m for megabytes. It is
important to note that this quota is not enforced by the remote server,
but is a client-side restriction managed entirely by wget
itself.
Behavior During Single vs. Multiple File Downloads
The exact behavior of wget depends on the context of the
download queue:
- Mid-File Exceedance: If
wgetis in the middle of retrieving a file and the quota limit is reached, it will not abruptly cut off the connection mid-stream. Instead, it completes the download of that current file. - Subsequent Files: Once the current file finishes
downloading,
wgetchecks the total bytes received against the specified quota. If the quota has been met or exceeded,wgetwill exit immediately and refuse to retrieve any remaining files in the queue.
Example Scenario
If you attempt to download a list of files with a set quota, the execution follows a strict sequential check:
- You run
wget --quota=10m -i download_list.txt. - The first file is 8 MB. It downloads completely. Total downloaded: 8 MB (under quota).
- The second file is 5 MB.
wgetstarts downloading it because the quota was not yet exceeded when the download began. - The second file completes. Total downloaded is now 13 MB.
wgetchecks the quota, realizes 13 MB exceeds the 10 MB limit, and exits. The remaining files indownload_list.txtare ignored.