How to ping to a file and with a timestamp

How to ping to a file and with a timestamp

Have you ever had the need to ping to a file but also know when the pings happened so you can analyze the data better. Here is on example :

Open Notepad and input the following :

@ECHO OFF
:LOOPSTART
echo %time% >> ping.txt
echo %time%
ping 172.17.10.11 -n 10 >> ping.txt
GOTO LOOPSTART

Change the IP Address to the desired one and also change the name of the output file if needed ( currently it is ping.txt ). It will be created in the directory from which you are running the batch file. Also note that the current batch file will do the ping infinitely. If you want to change that remove the “-n”. The number 10 specifies how many pings it will do before timestamping and starting on the new roll.

Now save the Notepad file as ping.bat ( or a different name ) and run it. The output should look like that :

You can also download a sample batch file and edit it for your own needs. Click here.

16:00:15,91

Pinging 172.17.10.11 with 32 bytes of data:
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128

Ping statistics for 172.17.10.11:
Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
16:00:24,98

Pinging 172.17.10.11 with 32 bytes of data:
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128

Ping statistics for 172.17.10.11:
Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
16:00:34,01

Pinging 172.17.10.11 with 32 bytes of data:
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128
Reply from 172.17.10.11: bytes=32 time<1ms TTL=128

 

3208 Total Views 5 Views Today

Leave a Reply

Your email address will not be published. Required fields are marked *