Add Timestamp to Ping

Robin Kim
therobinkim
Published in
1 min readSep 11, 2015

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.

--

--

Robin Kim
therobinkim

Full stack software engineer. I teach at Hack Reactor Remote @ Galvanize.