Shashikant shah

Tuesday 12 April 2016

“Ping” display time and date of ping

#!/bin/bash
logs_google="Ping_google"
logs_gmail="Ping_gmail"
remove_file=$(rm -rf $logs_google $logs_gmail)
# Continue ping 5 min
$(ping www.google.com -i 1 -c 300 | while read pong; do echo "$(date +%Y-%m-%d_%H:%M:%S): $pong"; done >> $logs_google & echo $! > pid_google)
$(ping www.gmail.com -i 1 -c 300 | while read pong; do echo "$(date +%Y-%m-%d_%H:%M:%S): $pong"; done >> $logs_gmail & echo $! > pid_gmail)

output :-

2016-04-06_19:12:08: PING www.google.com (74.125.68.99) 56(84) bytes of data.
2016-04-06_19:12:08: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=1 ttl=49 time=101 ms
2016-04-06_19:12:09: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=2 ttl=49 time=99.6 ms
2016-04-06_19:12:10: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=3 ttl=49 time=99.9 ms
2016-04-06_19:12:11: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=4 ttl=49 time=99.5 ms
2016-04-06_19:12:12: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=5 ttl=49 time=99.7 ms
2016-04-06_19:12:13: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=6 ttl=49 time=109 ms
2016-04-06_19:12:14: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=7 ttl=49 time=103 ms
2016-04-06_19:12:15: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=8 ttl=49 time=98.5 ms
2016-04-06_19:12:16: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=9 ttl=49 time=99.5 ms
2016-04-06_19:12:17: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=10 ttl=49 time=106 ms
2016-04-06_19:12:18: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=11 ttl=49 time=120 ms
2016-04-06_19:12:19: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=12 ttl=49 time=198 ms
2016-04-06_19:12:20: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=13 ttl=49 time=139 ms
2016-04-06_19:12:21: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=14 ttl=49 time=123 ms
2016-04-06_19:12:22: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=15 ttl=49 time=133 ms
2016-04-06_19:12:23: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=16 ttl=49 time=99.2 ms
2016-04-06_19:12:24: 64 bytes from sc-in-f99.1e100.net (74.125.68.99): icmp_seq=17 ttl=49 time=101 ms






===========================
1=sec
300sec=5min

No comments:

Post a Comment