Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit size wget can download

Tags:

bash

unix

wget

Is it possible to limit or cap the amount of data wget downloads from a site? Either via server setting or wget setting?

For example, one page is 1GB size, I want wget to stop downloading at 100MB.

like image 436
d-_-b Avatar asked Dec 03 '22 21:12

d-_-b


1 Answers

Leveraging the ability for the system to limit processes resource consumption through the ulimit command should just work. Assuming you use bash:

(ulimit -f 102400; wget $url)

Here the size is in 1024 bytes blocks. Note that if you use a different still standard compliant shell, or use bash in POSIX mode, the block size is 512 bytes so the command should be:

(ulimit -f 204800; wget $url)
like image 187
jlliagre Avatar answered Dec 11 '22 10:12

jlliagre