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 🙂

Maja Minnaert
  • November 6th, 2020


When attempting step 8 of this process,
“sudo speedtest-csv –header >> /cron/speedtest/speedtest.csv”

I keep running into the error:
“bash: /cron/speedtest/speedtest.csv: Permission denied”

I have tried:
– putting the path in my home folder ( ~/cron/speedtest )
– first creating the file with touch ( cd /cron/speedtest; touch speedtest.csv )
– finding out how the permissions work and adapting those settings ( i found a command line going “chmod u+x /cron/speedtest/speedtest.csv”. This gives a “Permission denied” error too.

I have also:
– googled, looked on stackoverflow, …

I seem to be missing something, be it complex or simple. Any way you could help?

Kind regards
Maja Minnaert

  • November 8th, 2020

Hi Maja,

I had the same issue a few weeks ago with this, which had been installed been working fine since 2018.

It turned out, updating Python solved the issue. Please can you try running: “sudo apt-get –only-upgrade install python-pip && sudo apt-get install python-pip” and restart your computer.

I have tried this tutorial to be sure everything is still correct. Run on a clean; up-to-date install of Ubuntu 18.04 and it still works okay.


Mr Ian Bunyard
  • January 19th, 2021

Hi Ryan, I am very new to using the Raspberry Pi and to the use of Linux in particular. I am interested in this application and I have followed the instructions in the Repo but have run into a problem of permission denied when executing the command “sudo speedtest-csv –header >> /cron/speedtest/speedtest.csv”

I have seen you earlier recommendation and I do have the latest version of python-pip installed as confirmed when I ran the instruction “sudo apt-get –only-upgrade install python-pip && sudo apt-get install python-pip. Do you have any suggestions on how permission can be obtained. Thanks Ian Bunyard.

  • January 19th, 2021

Hi Ian,

I have seen a few other people say they had a permission denied error. However I tried to replicate this with a fresh install of Ubuntu and did not experience the same issue.

Could you check if your user account has sudo privileges please. Run this command in the terminal, and see if ‘sudo’ is returned:


If not, you will have to give your user sudo privileges. See this post for more info:

Ian Bunyard
  • January 22nd, 2021

Thanks Ryan for your reply.

I have run ‘groups’ on my ‘zero’ with the latest update of Raspian installed and find that in the returned list sudo is included. I have overcome the problem by simply created the speedtest.csv file manually on the /cron/speedtest/ directory.

Out of interest when I ran the command again:
sudo speedtest-csv –header >> /cron/speedtest/speedtest.csv I still get the message
bash: /cron/speedtest/speedtest.csv: Permision Denied

So a work around has been found but interesting that the problem still persists

Regards Ian Bunyard.

  • January 27th, 2021

Hi Ian, the only other thing I can think of is to set file ownership on your .CSV to root, as when running the speedtest-csv command it will be run as the root user.

sudo chown root /cron/speedtest/speedtest.csv

  • April 8th, 2021

Anyone know of a Windows 10 compatible solution please?

  • April 9th, 2021

Hi, I’m not a Windows user myself, but there is a command line program you can use. Have you tried this?

It doesn’t come.bundles with .CSV saving, so this is something you will need to look into.

A Person of the internet
  • May 17th, 2021

I too am running Ubuntu server 20 on a raspi pi 3B + and have the same issue as Ian Bunyard, i too have worked around this as he did but i tried the same things and i still get the error of permission denied.

  • July 7th, 2021


Post a Comment