Add Timestamp to Ping
I modified the original suggestion of…
ping google.com | while read pong; do echo "$(date): $pong"; done
ping 220.127.116.11 | while read pong; do echo "$(date): $pong"; done >> 18.104.22.168.log
…to help troubleshoot Internet woes on OSX (Yosemite).
What I think this does:
The results of
ping 22.214.171.124 (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
126.96.36.199.log so the results can persist even if the computer accidentally restarts or whatnot) with the date prepended to the ping results.