Pages

Monday, July 22, 2013

how to get ping result with timestamp ?

# ping 172.11.23.103 | while read pong; do echo "$(date): $pong"; done >> /tmp/pingtest103.log


Tue Jul 23 09:04:33 AST 2013: PING 172.11.23.103 (172.11.23.103) 56(84) bytes of data.
Tue Jul 23 09:04:33 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=21 ttl=64 time=0.137 ms
Tue Jul 23 09:04:34 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=22 ttl=64 time=0.100 ms
Tue Jul 23 09:04:35 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=23 ttl=64 time=0.144 ms
Tue Jul 23 09:04:36 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=24 ttl=64 time=0.112 ms
Tue Jul 23 09:04:37 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=25 ttl=64 time=0.122 ms
Tue Jul 23 09:04:38 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=26 ttl=64 time=0.136 ms
Tue Jul 23 09:04:39 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=27 ttl=64 time=0.097 ms
Tue Jul 23 09:04:40 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=28 ttl=64 time=0.201 ms
Tue Jul 23 09:04:41 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=29 ttl=64 time=0.115 ms



After 16 hours:

# ls -lrth /tmp/pingtest103.log

-rw-r--r-- 1 root root 8.5M Jul 24 01:09 /tmp/pingtest103.log


No comments:

Post a Comment