How to Limit Wget Download Size on Ubuntu Linux
This article details how to restrict data usage when downloading files with wget on Ubuntu. It identifies the specific command-line options required to cap both cumulative download volumes and individual file sizes. Readers will find syntax examples to implement these limits immediately.
To limit the total amount of data downloaded during a recursive
session, use the --quota option. This flag sets a maximum
size for the entire retrieval process. If the total data downloaded
exceeds this limit, wget will stop automatically. This is particularly
useful when mirroring websites or downloading multiple files where
bandwidth or disk space is constrained.
The syntax for setting a download quota is as follows:
wget -r --quota=500m https://example.comIn this example, wget will recursively download content from the URL but will cease operation once 500 megabytes of total data have been transferred. You can specify the size in bytes, kilobytes (k), megabytes (m), or gigabytes (g).
If you need to limit the size of a single specific file rather than
the total session data, use the --max-filesize option. This
command aborts the download if the individual file exceeds the specified
limit. This ensures that no single large file consumes excessive
resources.
The syntax for limiting a single file size is:
wget --max-filesize=100m https://example.com/largefile.zipIn this case, if the file largefile.zip is larger than
100 megabytes, wget will stop downloading it. Combining these options
allows for precise control over data consumption on your Ubuntu
system.