23

I want update my linux in one shell but by default wget or axel in updater use all the bandwidth.

How can I limit the speed in this shell?

I want other shells to have a fair share, and to limit everything in that shell – something like a proxy!

I use Zsh and Arch Linux.

This question focuses on process-wide or session-wide solutions. See How to limit network bandwidth? for system-wide or container-wide solutions on Linux.

4 Answers 4

27

Have a look at trickle a userspace bandwidth shaper. Just start your shell with trickle and specify the speed, e.g.:

trickle -d 100 zsh

which tries to limit the download speed to 100KB/s for all programs launched inside this shell.

As trickle uses LD_PRELOAD this won't work with static linked programs but this isn't a problem for most programs.

2
  • Note that it's limited to SOCK_STREAMS sockets, so won't affect UDP traffic for instance. Commented Nov 15, 2019 at 18:38
  • I want to test myshell-ai/OpenVoice but why doesn't this command work with conda / pip? I shared another solution by limiting the bandwidth with Squid proxy. Commented Oct 11 at 20:51
5

http://lartc.org/wondershaper/

It is in Ubuntu / Debian repositories, probably others too. It limits not just a single shell, but the whole machine. Never tried it myself though

2

The man page for wget provides the following information:

 --limit-rate=amount

Limit the download speed to amount bytes per second. Amount may be expressed in bytes, kilobytes with the k suffix, or megabytes with the m suffix. For example, --limit-rate=20k will limit the retrieval rate to 20KB/s. This is useful when, for whatever reason, you don't want Wget to consume the entire available bandwidth.

3
  • update question: i want all application limited, not only wget Commented May 26, 2012 at 11:15
  • @Efazati: Sorry I don't know how to set it in general. I use it only for wget and apt-get. Commented May 26, 2012 at 11:24
  • don't wory man, just wating for answer ;) Commented May 26, 2012 at 11:25
0

The trickle solution did not work when I wanted to test https://github.com/myshell-ai/OpenVoice, it downloaded a lot of data with conda (miniforge) / pip which prevented me browsing Internet at the same time.

However I found another solution by limiting the bandwidth with Squid proxy, I had to add for example this data in /etc/squid/squid.conf for 128 kbps (16 kB/s) like explained on https://superuser.com/questions/66574/how-to-throttle-bandwidth-on-a-linux-network-interface/285721#285721 before restarting Squid (I later increased the values to half of my Internet connection speed):

delay_pools 1
delay_class 1 1
delay_access 1 allow all
delay_parameters 1 16000/16000 

Then in the shell, I just had to use the proxy like this:

export http_proxy=http://localhost:3128; export https_proxy=$http_proxy

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.