This command will give you a timestamped continuous ping:
ping -t 8.8.8.8|cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo(!date! !time! !data!)&ping -n 2 8.8.8.8>nul"
You can replace the two 8.8.8.8 addresses with whatever IP address you are trying to ping
Press Ctrl + C to end the ping
You can also send the output directly to a text file.
This command sends output of ping to 8.8.8.8 to C:\pingtest.txt
ping -t 8.8.8.8|cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo(!date! !time! !data!)&ping -n 2 8.8.8.8>nul" >C:\pingtest.txt
You can replace the two 8.8.8.8 addresses with whatever IP address you are trying to ping, and C:\pingtest.txt with whatever location and file name you want to send the output to.
Don't forget to press Ctrl + C in the command window to end the ping
Sources:
https://www.raymond.cc/blog/timestamp-ping-with-hrping/
In what scenario would I need to use this command? Like how is different from the usual ping apart from the obvious?
ReplyDeleteHi Mohau, thanks for reading. This command proved useful at work mainly during testing and monitoring scenarios. For instance, at one point at my job we were running network and WAN overload type tests during a specific window, and continuous pings to the outside as well as various remote internal addresses were requested as a simple way to see when connectivity was lost.
DeleteThis command at least gave me an exact time stamp, which is different than a regular ping from my experience (does not have a time-stamp). I could kick off the pings for a live look, or kick off with the output to a text file option and let run for as long as the test period was. We could then compare the time stamps of the ping timeouts to the network load time stamps for the application that was running and see where & when it was maxing out.
Thankfully now there are other resources like WUG or Solar Winds in place to get more detailed data like Top Talkers, but I have found it handy to have an exact timestamped ping entry on several occasions nonetheless.
HI, when I tried the command, giving error as access denied, i tried opening command prompt as administrator, please assist
ReplyDeleteHello - you should be able to run the command line without needing elevated privileges, and is a basic command syntax that does not (ordinarily) need permissions to run. Depending on your current security configuration, if the error persists perhaps investigate local admin rights or if restrictions are in place by like a company entity/enterprise policy, etc.
DeleteWhen I press the cammand control c then stop the ping but not showing average maximum minimum latency and statics please share the cammand
ReplyDeleteGood observation, thanks for bringing it up! I have recently been trying to figure out that conundrum...supposedly Ctrl-Break is an option and alternative to Ctrl-C for continuous ping command that might work, but I have not found a working "break" key or key sequence yet with, at least for an HP with Windows 10. I just installed their updated HotKey-support driver, so will see if that makes a difference with being able to possibly end the scripted command while allowing the ping statistic output, along with possibly messing with keyboard scancode maps in the Registry to "set" a break key. I'll update the post once I get it figured out!
DeleteI can't thank you enough. Works great!!!!
ReplyDeleteNice thanks very much
ReplyDeleteI am seeing disparity in the timestamp when the connection resumes after disconnection.
ReplyDeletefor e.g. timestamp after 10:25:58.81 has jumped back to 10:25:52.73 in the next ping
Wed 07/14/2021 10:25:58.81 General failure.
Wed 07/14/2021 10:25:52.73 PING: transmit failed. General failure.
Any idea why is this happening? I am redirecting the output to a text file. Below is the reference of the complete session
Wed 07/14/2021 10:25:37.25 Reply from 8.8.8.8: bytes=32 time=44ms TTL=109
Wed 07/14/2021 10:25:38.32 Reply from 8.8.8.8: bytes=32 time=41ms TTL=109
Wed 07/14/2021 10:25:39.39 Reply from 8.8.8.8: bytes=32 time=43ms TTL=109
Wed 07/14/2021 10:25:40.45 Reply from 8.8.8.8: bytes=32 time=41ms TTL=109
Wed 07/14/2021 10:25:41.52 Reply from 8.8.8.8: bytes=32 time=45ms TTL=109
Wed 07/14/2021 10:25:42.59 Reply from 8.8.8.8: bytes=32 time=42ms TTL=109
Wed 07/14/2021 10:25:43.65 Reply from 8.8.8.8: bytes=32 time=44ms TTL=109
Wed 07/14/2021 10:25:48.39 Request timed out.
Wed 07/14/2021 10:25:49.40 General failure.
Wed 07/14/2021 10:25:50.41 General failure.
Wed 07/14/2021 10:25:51.52 General failure.
Wed 07/14/2021 10:25:52.54 General failure.
Wed 07/14/2021 10:25:53.56 General failure.
Wed 07/14/2021 10:25:54.58 General failure.
Wed 07/14/2021 10:25:55.60 General failure.
Wed 07/14/2021 10:25:56.77 General failure.
Wed 07/14/2021 10:25:57.79 General failure.
Wed 07/14/2021 10:25:58.81 General failure.
Wed 07/14/2021 10:25:52.73 PING: transmit failed. General failure.
Wed 07/14/2021 10:25:53.75 PING: transmit failed. General failure.
Wed 07/14/2021 10:25:54.76 PING: transmit failed. General failure.
Wed 07/14/2021 10:25:55.84 Reply from 8.8.8.8: bytes=32 time=64ms TTL=109
Wed 07/14/2021 10:25:56.90 Reply from 8.8.8.8: bytes=32 time=53ms TTL=109
Wed 07/14/2021 10:25:57.96 Reply from 8.8.8.8: bytes=32 time=43ms TTL=109