Skip to main content

tping - ping with a timestamp

Published: 03-09-2018 | Author: Remy van ElstText only version of this article

Table of Contents

tping is a bash alias I once got from an old co-worker. It's ping, but with a timestamp. Instead of looking at the increased icmp_seq number you now have a timestamp. Here's how it looks like:

$ tping
09:31:55: PING ( 56(84) bytes of data.
09:31:55: 64 bytes from ( icmp_seq=30 ttl=63 time=0.399 ms
09:31:56: 64 bytes from ( icmp_seq=31 ttl=63 time=0.530 ms
09:31:57: 64 bytes from ( icmp_seq=32 ttl=63 time=0.412 ms
09:31:58: 64 bytes from ( icmp_seq=33 ttl=63 time=0.469 ms
09:31:59: 64 bytes from ( icmp_seq=34 ttl=63 time=0.383 ms
09:32:00: 64 bytes from ( icmp_seq=35 ttl=63 time=0.402 ms
09:32:01: 64 bytes from ( icmp_seq=36 ttl=63 time=0.483 ms
09:32:02: 64 bytes from ( icmp_seq=37 ttl=63 time=0.409 ms
09:32:03: 64 bytes from ( icmp_seq=38 ttl=63 time=0.346 ms

09:36:20: 64 bytes from ( icmp_seq=289 ttl=63 time=1.51 ms
09:36:21: 64 bytes from ( icmp_seq=290 ttl=63 time=0.474 ms
09:36:22: 64 bytes from ( icmp_seq=291 ttl=63 time=0.698 ms
09:36:23: 64 bytes from ( icmp_seq=292 ttl=63 time=0.483 ms
09:36:24: 64 bytes from ( icmp_seq=293 ttl=63 time=0.482 ms
09:36:25: 64 bytes from ( icmp_seq=294 ttl=63 time=0.619 ms
09:36:26: 64 bytes from ( icmp_seq=295 ttl=63 time=0.498 ms
09:36:27: 64 bytes from ( icmp_seq=296 ttl=63 time=0.491 ms

The host went down on 09:32 and was back up on 09:36. This was a scheduled reboot.

If you like this article, consider sponsoring me by trying out a Digital Ocean VPS. With this link you'll get a $5 VPS for 2 months free (as in, you get $10 credit). (referral link)

.bashrc function

The shell code for in your .bashrc file:

tping() {
    ping $@ | while read pong; do 
        echo "$(date +"%T"): $pong"; 
alias tping=tping

Start a new shell our source .bashrc after you added this function.


Another tool to get more visual information from ping is prettyping. It's open source on github and looks like this:

The red exclamation marks in the image represent a reboot of that server.

Tags: bash  monitoring  ping  shell  snippets  tping