Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Linux/Internet Test

June 26, 2020

Internet Test

My internet has been flaky lately. I wrote a script that logs my internet connection.

I’m running it in cron every minute.

#!/bin/bash
log='/home/ulysses/Code/spectrum.log'
if nc -zw1 google.com 443;
then 
  echo 'Spectrum is up' $(date) >> $log
else 
  echo 'Spectrum is down' $(date) >> $log
fi

#!/bin/bash log='/home/ulysses/Code/spectrum.log' if nc -zw1 google.com 443; then echo 'Spectrum is up' $(date) >> $log else echo 'Spectrum is down' $(date) >> $log fi

To view, just cat the log.

cat spectrum.log 
Spectrum is up Fri Jun 26 15:14:01 EDT 2020
Spectrum is up Fri Jun 26 15:15:01 EDT 2020
Spectrum is up Fri Jun 26 15:16:01 EDT 2020
Spectrum is up Fri Jun 26 15:17:01 EDT 2020
Spectrum is up Fri Jun 26 15:18:01 EDT 2020

cat spectrum.log Spectrum is up Fri Jun 26 15:14:01 EDT 2020 Spectrum is up Fri Jun 26 15:15:01 EDT 2020 Spectrum is up Fri Jun 26 15:16:01 EDT 2020 Spectrum is up Fri Jun 26 15:17:01 EDT 2020 Spectrum is up Fri Jun 26 15:18:01 EDT 2020

So, I now have a record when it was up or down.

Filed Under: Linux Tagged With: connection, internet, log, spectrum

Have content delivered to your mail. Subscribe below.

About Me

I'm Ulysses, Cloud Engineer at Cardinal Health based in Columbus. This blog is about Linux and Cloud technology. When off the grid, I enjoy riding my electric skateboard. I've surfed, snowboarded and played the saxophone in the past. I hope you find this website helpful. It's powered by WordPress and hosted on AWS LightSail.

  • Cloud
  • Linux
  • Git

Copyright © 2012–2021