Add Timestamp to Ping

Resource: http://tech.jocke.no/2010/09/27/add-timestamp-to-ping/

I modified the original suggestion of… 
 ping google.com | while read pong; do echo "$(date): $pong"; done

to… 
 ping 8.8.8.8 | while read pong; do echo "$(date): $pong"; done >> 8.8.8.8.log

…to help troubleshoot Internet woes on OSX (Yosemite).

What I think this does:

The results of ping 8.8.8.8 (which come about every second or so) are piped into the while read statement. The ping results are assigned a new variable name of pong. Then, the results are printed to the output (typically the terminal, but I changed it to a file called 8.8.8.8.log so the results can persist even if the computer accidentally restarts or whatnot) with the date prepended to the ping results.

Like what you read? Give Robin Kim a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.