리눅스 ping 시간 표시

How to timestamp every ping result
ping 시간 표시하기
Ping 시간값 표시

1 방법[편집]

명령어
ping 서버주소 | xargs -I{} echo `date` {}
ping 서버주소 | xargs -I{} date '+%F %T {}'
ping 서버주소 | awk '{print strftime()" "$0}'
ping 서버주소 | while read n; do echo $(date) $n; done

2 실행예시 1: xargs[편집]

[root@zetawiki ~]# ping 8.8.8.8 | xargs -I{} echo `date` {}
Mon Nov 11 01:19:56 KST 2013 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
Mon Nov 11 01:19:56 KST 2013 64 bytes from 8.8.8.8: icmp_seq=1 ttl=45 time=64.6 ms
Mon Nov 11 01:19:56 KST 2013 64 bytes from 8.8.8.8: icmp_seq=2 ttl=45 time=65.7 ms
... (생략)
[root@zetawiki ~]# ping 8.8.8.8 | xargs -I{} date '+%F %T {}'
2013-11-11 01:02:26 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
2013-11-11 01:02:26 64 bytes from 8.8.8.8: icmp_seq=1 ttl=45 time=63.8 ms
2013-11-11 01:02:27 64 bytes from 8.8.8.8: icmp_seq=2 ttl=45 time=64.4 ms
... (생략)
→ 표준 날짜 표기


3 실행예시 2: awk[편집]

[root@zetawiki ~]# ping 8.8.8.8 | awk '{print strftime()" "$0}'
Mon Nov 11 01:09:32 KST 2013 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
Mon Nov 11 01:09:32 KST 2013 64 bytes from 8.8.8.8: icmp_seq=1 ttl=45 time=67.6 ms
Mon Nov 11 01:09:33 KST 2013 64 bytes from 8.8.8.8: icmp_seq=2 ttl=45 time=65.2 ms
... (생략)

4 실행예시 3: while[편집]

[root@zetawiki ~]# ping 8.8.8.8 | while read n; do echo $(date) $n; done
Mon Nov 11 01:03:08 KST 2013 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
Mon Nov 11 01:03:08 KST 2013 64 bytes from 8.8.8.8: icmp_seq=1 ttl=45 time=63.9 ms
Mon Nov 11 01:03:09 KST 2013 64 bytes from 8.8.8.8: icmp_seq=2 ttl=45 time=63.9 ms
... (생략)

5 같이 보기[편집]

6 참고[편집]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}