Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
Created June 28, 2017 02:18
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ntrepid8/d6f0fafa57a42ca1b515c19e71492309 to your computer and use it in GitHub Desktop.
Save ntrepid8/d6f0fafa57a42ca1b515c19e71492309 to your computer and use it in GitHub Desktop.
Script to run speedtest-cli via cron and log the results
#!/usr/bin/env bash
LOG_PATH="/home/$(whoami)/log/speedtest.log"
if result=$(/usr/bin/speedtest --simple); then
parsed_result=$(printf "${result}\"" | sed ':a;N;$!ba;s/\n/" /g' | sed 's/: /="/g')
printf "[$(date)] ${parsed_result}\n" >> "${LOG_PATH}"
else
printf "[$(date)] error\n" >> "${LOG_PATH}"
exit 1
fi
exit 0
@Anthonycom
Copy link

Thanks. Edited line 3 and 5. Working like a charm

@ethanrusz
Copy link

Came in handy after changing /usr/bin/speedtest to /usr/bin/speedtest-cli. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment