Create a time and date-stamped ping

22 January 2016, 03:46

If you need to run a constant ping and want each ping to have the time and date attached, the following single-line command will do the trick. For what it’s worth, this’ll work on Linux and Unix too, and in fact any BASH-equipped system:

ping 192.168.1.1 | while read pong; do echo "$(date): $pong"; done

It’ll keep going until you kill it via Ctrl+C (that’s Ctrl, not Cmd!).

Obviously you should replace 192.168.1.1 with the address you want to ping. If just checking for internet connectivity you can ping Google’s public DNS servers – 8.8.8.8 – in which case the following will do the trick nicely:

ping 8.8.8.8 | while read pong; do echo "$(date): $pong"; done



Leave a comment...

 
---