Get speedtest-cli from here: https://github.com/sivel/speedtest-cli
Lazy option:
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py chmod +x speedtest-cli
Add entry to crontab:
*/15 * * * * cd /home/user && (./speedtest-cli --simple | tr "\n" "\t" && date "+\%F\\ \%T") >> speedtest.log
Every 15 minutes this will add line to the /home/user/speedtest.log that looks like this:
Ping: 179.666 ms Download: 135.96 Mbit/s Upload: 12.39 Mbit/s 2020-07-21\ 06:49:29