Created
March 26, 2021 10:26
-
-
Save ohbus/b74e6c16da47f203887e169e3fc6b026 to your computer and use it in GitHub Desktop.
Speed Test your Internet every hour and log the output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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