Skip to content

Instantly share code, notes, and snippets.

@ohbus
Created March 26, 2021 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohbus/b74e6c16da47f203887e169e3fc6b026 to your computer and use it in GitHub Desktop.
Save ohbus/b74e6c16da47f203887e169e3fc6b026 to your computer and use it in GitHub Desktop.
Speed Test your Internet every hour and log the output
#!/usr/bin/bash
LOG_PATH="/home/ubuntu/speedtest/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment