Back when I used linux there was a program that would find you the fastest Debian package repository based on your location. Is there a similar one for CTAN? I've been manually picking ones that I think are physically close to me and basing it on the ping time, but that isn't super reliable. Just asking as I'm on a 100+ MBit/s download connection, but it still takes hours for me to install LaTeX and a very long time to update packages.
-
I've got a much slower Internet connection and the full TL installs within 45minutes.– user31729Commented Jan 7, 2016 at 20:23
-
@HenriMenke Wouldn't the fact that is on a different continent from me slow things down some?– CanageekCommented Jan 7, 2016 at 20:28
-
@Canageek You can at least see which mirrors are up here.– Henri MenkeCommented Jan 7, 2016 at 20:41
-
@HenriMenke TeXLive Manager will give me a list of mirrors, but I can only guess where they are physically located (which worked fine when I lived down the road from a uni hosting one of them, but now that I'm 4500 km away I get much slower rates from that mirror)– CanageekCommented Jan 7, 2016 at 20:44
-
Why do you specify one at all? Did you have problems letting it pick automatically?– cfrCommented Jan 7, 2016 at 22:07
2 Answers
Assuming you're on Linux you can use this command to find the fastest mirror:
netselect -vv -t40 -s20 $(\
curl -sSL http://dante.ctan.org/mirmon/ | \
grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | \
cut -d\" -f2 \
) | \
cut -c7- | \
LC_ALL=C xargs -tn1 -i curl -sSL -w "%{time_total} %{speed_download} {}\n" -o /dev/null {}FILES.byname | \
sort -n
This will give you the 20 fastest mirrors (actually measured download speed). It'll rank them by speed (fastest on top) and tell you how long it took to download the file list (/FILES.byname
) and the average download speed.
It's also a fair bit verbose and will tell you what it does along the way. You can reduce the verbosiy by removing the -t
flag in the xargs
command and by removing 1 or both -v
flags from the netselect
command. Adjust the number of total servers you want to check for download speed with the parameter -s20
.
Below is a version you can use in a shell script, that will only output the fastest mirror and nothing else. Very usefull for shell scripts.
netselect -t40 -s20 $(\
curl -sSL http://dante.ctan.org/mirmon/ | \
grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | \
cut -d\" -f2 \
) | \
cut -c7- | \
LC_ALL=C xargs -n1 -i curl -sSL -w "%{time_total} {}\n" -o /dev/null {}FILES.byname | \
sort -n | \
head -n1 | \
cut -d\ -f2
netselect
is no longer available using Ubuntu, so I've included a more general (if much slower) version of this answer that does not rely on it:
curl -sSL http://dante.ctan.org/mirmon/ | grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | cut -d\" -f2 | LC_ALL=C xargs -n1 -i curl -sSL -w "%{time_total} %{speed_download} {}\n" -o /dev/null {}FILES.byname | sort -n
This wasn't working for me today for some reason, so I used:
#!/bin/bash
if [ -z "$1" ]
then
for mirror in `curl -sSL http://dante.ctan.org/mirmon/ | grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | cut -d\" -f2`
do
(
host=`echo $mirror |sed s,.*//,,|sed s,/.*,,`
echo -e `ping $host -c1 | grep time=|sed s,.*time=,,`:' \t\t'$mirror
) &
done
wait
exit 1
fi
and then piped that to sort -n
-
Choose Arch :). AUR still has it. Don't know if it still works, mind: last updated 25th Sep 2018!– cfrCommented Nov 26, 2020 at 4:53
-
Well, the second one won't work on my machine since I am behind a proxy, so
ping
outside the LAN does not work. I am able to use curl with the--proxy
option, socurl --proxy 'http.proxy.firm.de:1234' -sSL http://dante.ctan.org/mirmon/
works. The first command, however, is very slow. Any chance to modify the second command to not useping
? Or somehow pass the proxy as argument?– winkmalCommented Dec 19, 2022 at 9:35 -
1With the
-m
flag for max. timeout, I used the first command and it worked. So with the two additional arguments:... curl
-x 'http.proxy.firm.de:1234' -m 11
-sSL -w "%{time_total} %{speed_download} {}\n" ...
– winkmalCommented Dec 20, 2022 at 8:21