Monday, February 6, 2017

Ping any domain with Real time (Timestamp)

I needed a command which can ping any server & show timestamp as well

ping google.com | awk '/^[0-9]+ bytes from / { "date" | getline pong; close("date"); print pong":",$0; }'

If you’re interested in all types of replies (unreachable, no route to host, etc), the following should work on most systems;

ping google.com | while read pong; do echo "$(date): $pong"; done


No comments:

Post a Comment