How to lower wait time for repository updates
How can I lower the time so that if a particular repository takes more than 10 seconds to connect or finish it should ignore it and move the following ones?
Mirrors are one option, as @adempewolff explained. Let me give you a direct answer though:
Setting apt-get connection timeouts
You can control these timeouts via the following apt.conf
options:
Acquire::http::Timeout "10"; Acquire::ftp::Timeout "10";
Note that this only applies to connection timeouts, NOT "finish time" timeouts, i.e. if it connects within 10 seconds, it will continue to download a 100MB package even if it's at 1 KB/second :)
To implement these options, simply create a conf file in /etc/apt/apt.conf.d
; suppose we call it 99timeout
.
- Press
Alt+F2
, typegksudo gedit /etc/apt/apt.conf.d/99timeout
- Type/paste the above lines, with your choice of timeout in seconds
- Save and exit.
- Now try
sudo apt-get update
And the terminal-addict's "find best server" hack!
Expanded and moved as an answer to this more appropriate question
Additional apt-get conf options that you can try to tweak
Acquire::Queue-Mode
: Queuing mode; Queue-Mode can be one ofhost
oraccess
which determines how APT parallelizes outgoing connections.host
means that one connection per target host will be opened,access
means that one connection per URI type will be opened.Acquire::Retries
: Number of retries to perform. If this is non-zero APT will retry failed files the given number of times.Acquire::http::Dl-Limit
: accepts integer values in kilobytes, to throttle download speed and not slow down your browsing/email/etc. when updating. The default value is 0 which deactivates the limit and tries uses as much as possible of the bandwidth. If enabled, it will disableapt-get
's parallel downloading feature.Dig through
man apt.conf
if you think something else might help!
Often certain repositories loading painfully slow is just a symptom of using a slow mirror. The default mirrors for many regions are not the fastest (I know this is the case in China).
Changing your mirror is really easily done through the Software Sources GUI, you can open this window in two ways:
- Open
Ubuntu Software Center
and click onSoftware Sources
in theEdit
menu.
or
- Open a terminal (or type
alt-F2
) and runsoftware-properties-gtk
When this window comes up you'll notice a drop down menu saying Download From:
that selects your mirror. Select the Other
option from this menu.
In the new window that comes up click the Select Best Server button and this will test and automatically choose the fastest server for your location.
Hope this helps!
See also:
- How can I get apt to use a mirror close to me, or choose a faster mirror?
apt-fast works like apt-get, but downloads repository updates and packages in parallel. See this tutorial to learn how to use it.