Using Speedtest-CLI to record speed tests to CSV via CRON

One of the most common speed testing services for Internet connections is Ookla’s Speedtest, and more often than not your ISP will either throttle your connection, or their network will slow down at peak times.

Because of this, I wanted to make sure I am receiving the full connection speed which I am paying for.

I went looking for a solution and immediatly came across Speedtest-CLI by Matt Martz. This repo allows you to perform Speedtests through a command line interface.

But I was still looking for some sort of tool which could convert these results to a CSV file, so a new row can be appended to the file each time a test was run. Again, I went searching and came accross the fantastic Speedtest-CLI-Extras project by Henrik Bengtsson. This repo allows you to run the Speedtest CLI command but export the results to a CSV file. This will become useful to build graphs and check results over time.


So let’s start. The installation process is painless, you will require Python install (python-pip). These installation notes were tested on Ubuntu 18.04.

These instructions can be found in my Github repo here.


  1. Switch to the root user:

    sudo su
  2. Install speedtest-cli, run each line separately:

    sudo apt-get install python-pip
    sudo pip install speedtest-cli
  3. Download the speedtest-csv script. You will also find a copy of this script within the repo which you can, or re-download from the original author and make the changes to the file mentioned in step 5.

    sudo wget -O speedtest-csv
  4. Now give the file execute permissions:

    sudo chmod +x speedtest-csv
  5. You will need to edit a line in the file to so that it can be run from CRON:

    sudo nano speedtest-csv

    Find the line cmd="speedtest-cli $opts" and add /usr/local/bin/ before it so it reads:

    cmd="/usr/local/bin/speedtest-cli $opts"

    save the file and exit.

  6. Next move speedtest-csv to /usr/bin/:

    sudo mv speedtest-csv /usr/bin/
  7. Create a folder for where your .csv file will be saved, I am saving mine within /cron/speedtest/, but change this for whatever you’d like:

    sudo mkdir -p /cron/speedtest
  8. Generate the CSV header:

    sudo speedtest-csv --header >> /cron/speedtest/speedtest.csv
  9. Add to the CRON:

    sudo crontab -e
  10. Add the following line to the end of the file, this example is daily, ever four hours:

    0 */4 * * * speedtest-csv >> /cron/speedtest/speedtest.csv

    save the file and exit.


  • March 16th, 2019

In step 7.Generate the CSV header:
I get “/cron/speedtest/speedtest.csv: file or foilder does not exist”

  • March 16th, 2019


You will have to ensure the /cron/speedtest/ folders already exist. I have amended the instructions now.

Try this:

sudo mkdir -p /cron/speedtest

  • May 20th, 2020

Super , really worked well for me. Thank you !!

  • May 20th, 2020

Thanks, I’m glad to hear 🙂

Post a Comment