Ping returns this by default:
64 bytes from 203.173.50.132: icmp_seq=0 ttl=244 time=57.746 ms
Is there some way I can get it to add the timestamp?
For example,
Mon 21 May 2012 15:15:37 EST | 64 bytes from 203.173.50.132: icmp_seq=0 ttl=244 time=57.746 ms
I'm on OS X v10.7 (Lion) which seems to have some BSD version of ping.
Fortunately, ping on macOS lets you easily add a timestamp with a single additional option. Just enter ping --apple-time <IP address> to see the time a packet was received, right down to the microsecond.
I could not redirect the Perl based solution to a file for some reason so I kept searching and found a bash
only way to do this:
ping www.google.fr | while read pong; do echo "$(date): $pong"; done
Wed Jun 26 13:09:23 CEST 2013: PING www.google.fr (173.194.40.56) 56(84) bytes of data. Wed Jun 26 13:09:23 CEST 2013: 64 bytes from zrh04s05-in-f24.1e100.net (173.194.40.56): icmp_req=1 ttl=57 time=7.26 ms Wed Jun 26 13:09:24 CEST 2013: 64 bytes from zrh04s05-in-f24.1e100.net (173.194.40.56): icmp_req=2 ttl=57 time=8.14 ms
The credit goes to https://askubuntu.com/a/137246
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With