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.
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
- 271
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
- 17,935
-
Choose Arch :). AUR still has it. Don't know if it still works, mind: last updated 25th Sep 2018! – cfr Nov 26 '20 at 04:53
-
Well, the second one won't work on my machine since I am behind a proxy, so
pingoutside the LAN does not work. I am able to use curl with the--proxyoption, 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? – winkmal Dec 19 '22 at 09:35 -
1With the
-mflag 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" ...– winkmal Dec 20 '22 at 08:21
reflectorwhich you run to find the fastest mirrors for Arch Linux, so you could look at how that works, maybe? – cfr Dec 02 '20 at 03:52