Skip to content

Instantly share code, notes, and snippets.

@alexklibisz
Created October 20, 2014 04:16
Show Gist options
  • Save alexklibisz/23f1c5751ec28a25711d to your computer and use it in GitHub Desktop.
Save alexklibisz/23f1c5751ec28a25711d to your computer and use it in GitHub Desktop.
Unix shell script that logs the results of an Internet speed test (using speedtest-cli)
#!/bin/bash
# Alex Klibisz (10/2014)
# Shell script which will call the python speedtest-cli (https://github.com/sivel/speedtest-cli)
# and write the results to two log files - one with simple results, one with verbose results -
# prepended by the date/time of the speed test.
# This script should be either included in the same directory as the speedtest-cli files or
# the speedest-cli.py should be added to the /usr/bin (can use soft link).
# To use, specify the paths to your desired simple and verbose logs in the following 2 lines:
log_simple="/var/www/html/speedtest/speedtest.log"
log_verbose="/var/www/html/speedtest/speedtest_verbose.log"
now="$(date +'%Y/%m/%d %T')"
#simple speed test
printf "$now\n" >> "$log_simple"
speedtest_cli.py --simple >> "$log_simple"
printf '\n' >> "$log_simple"
#verbose speed test
printf "$now\n" >> "$log_verbose"
speedtest_cli.py >> "$log_verbose"
printf '\n' >> "$log_verbose"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment