How to Limit Wget Download Size on Ubuntu
This article provides a concise overview of how to control data usage
when downloading files using the command line in Ubuntu. It specifically
identifies the native wget option used to set a maximum
limit on the amount of data retrieved, ensuring you do not exceed
specific storage or bandwidth quotas during a download session.
The primary option that allows wget to specify a maximum
download size is --quota. This flag sets the total
retrieval quota for the session, meaning wget will stop
downloading once the specified amount of data has been transferred. This
is useful for preventing large files from consuming all available disk
space or exceeding data caps on metered connections.
To use this option, append --quota followed by the
desired size to your command. You can specify the size in bytes, or use
suffixes like k for kilobytes, m for
megabytes, and g for gigabytes. For example, to limit the
download to 50 megabytes, you would run the following command in your
terminal:
wget --quota=50m https://example.com/large-file.zipIt is important to understand that --quota applies to
the total amount of data downloaded in a single wget
invocation. If you are downloading multiple files in one command, the
limit applies to the sum of all files. If the quota is reached before a
file completes, wget will terminate the connection. This
makes it an effective tool for managing overall session size rather than
truncating individual files precisely, though it serves the purpose of
enforcing a maximum size constraint effectively.