I often have to ping servers for connectivity status. Is there a way to save the ping results (output) in a text file so that I can save entire day's ping results in a text file.

I am using Windows XP SP3.

Ping example:

ping -t 

(using windows' ping)



(using cygwin)

8 Answers 8


Use redirection, for example:

ping -t > filename.txt

This will redirect all (standard) output from the program into filename.txt, which will be created if it doesn't exist and overwritten if it does.

You can use >> instead of > to redirect the output to a file and append the results to the end of the file, instead of overwriting (with thanks to @Jane T for the reminder).

Note that you will not receive the normal on-screen output if you do this.

Update in response to comment

To delay between pings and record the time of each, you can do some scripting.

Here is a quick Windows batch file I've thrown together. It prints the time, pings Google, then waits for 3 seconds before repeating itself. I'm not a batch file expert so if anyone spots any problems please flag them up! And this probably isn't the "best" way to achieve what you are after - that might make for a separate question really.



time /T
ping www.google.com -n 4
sleep -m 3000


Save this in a .bat file somewhere, edit the ping target and delay time as you need it, then run the .bat using redirection to pump the output of the whole thing to a file. You may need to replace the sleep -m 3000 command with timeout /T 3 depending on your Windows version.

Note that this batch file never ends, but can be terminated by Ctrl + C and then Y if run from cmd. (You must press Y because it asks if you want to stop the batch file - even though you cannot see the question because you've redirected the output!)

  • thanks! works well, can I show current time along with every ping, or can I change the duration between two pings
    – abel
    Oct 7, 2010 at 12:22
  • 2
    You'd have to do some scripting for this, ping won't be able to do it for you.
    – Azz
    Oct 7, 2010 at 12:25
  • Azz beat me to it - for that you'd need to change ping itself to output something different, or do some interesting scripting effort to - for example - output a timestamp, ping, wait 10seconds, repeat.
    – DMA57361
    Oct 7, 2010 at 12:28
  • glad to hear it can be done. waiting for more. has windows scripting got to do anything with this
    – abel
    Oct 7, 2010 at 12:32
  • 2
    "so that I can save entire day's ping results in a text file" You will need to use >> to append data to the output file.
    – Jane T
    Oct 7, 2010 at 12:51

If you are using the command prompt just redirect it to a text file using this format

ping > ping.txt

That will do it.


You can use:

> ping -t > ping-results
  • 1
    Using > as your PS1 shell prompt is really confusing when the command also includes a > for redirection. Aug 22, 2020 at 20:24

I wrote the script that pings google.com every 5 seconds and logging results with current time. Here you can find output to variables "commandLineStr" (with indices)

@echo off


echo %DATE:~0% %TIME:~0,8% >> Pingtest.log

SET scriptCount=1
FOR /F "tokens=* USEBACKQ" %%F IN (`ping google.com -n 1`) DO (
  SET commandLineStr!scriptCount!=%%F
  SET /a scriptCount=!scriptCount!+1
@ECHO %commandLineStr1% >> PingTest.log
@ECHO %commandLineStr2% >> PingTest.log

timeout 5 > nul


Also if you want to see the ping results in display you can use this code

date /T >>Pingtest.log
time /T >>Pingtest.log
REM this line show you the ping results in display
ping -n 1 

REM this line print the ping results in the log file
ping -n 10 >>PingTest.log
sleep -m 1000

::PIng ISP Every 1 Seconds and write date , time and result to Text File

date /T >>Pingtest.log
time /T >>Pingtest.log
ping -n 1 >>PingTest.log
sleep -m 1000

Try this


ping -i 0.5  google.com | while read pingresponse; do echo "$(date): $pingresponse"; done > pingStream.txt
  • 1
    (1) @AndrewMorton: I’m not sure that your comment is entirely valid, since the question indicates that Cygwin is available.  But (2) saxjax: What’s with the -i?  My Windows ping says “Bad value for option -i, valid range is from 1 to 255.” and my Cygwin ping doesn’t recognize -i at all.  Also, (3) we don’t like code-only answers.  It is better to explain what your code is doing and how it is doing it. Aug 22, 2020 at 20:19


Create one file called ip.txt and type the IPs and create the .bat file below.

@Echo Off

Set "ServerList=C:\Users\Script Ping-NSLook\ip.txt"
Set "LogFile=C:\Users\Script Ping-NSLook\PingResults.txt"

If Not Exist "%ServerList%" Exit /B
>"%LogFile%" (For /F UseBackQ %%A In ("%ServerList%"
) Do Ping -n 1 %%A|Find "TTL=">Nul&&(Echo Yes [%%A])||Echo No [%%A])


  • 1
    Welcome to SuperUser! How is your answer better than the accepted one? If you write a so similar answer, please explain in which aspect yours is better. May 4, 2022 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.