Learn how to ping to a log file with a timestamp to troubleshoot network or device anomalies. This simple Windows batch script is very useful.
Why Would You Want to Ping to Log File With a Timestamp?
The need may arise to ping a device on the network, any device, to test the device or connectivity to the device.
Sometimes device or network problems are not immediately obvious and may require prolonged testing.
The Batch Script
You can download the batch script and modify by editing with notepad or similar. Security policies may prevent you from downloading .bat files. If that is the case just copy the text below and paste into your favourite text-editor, modify and save as .bat to run.
I found the sample on Stack Overflow so I’m not taking credit for it, but since I use it often enough I figured you might too.
ping -t 192.168.1.31|cmd /q /v /c "(pause&pause)>nul & for /l %%a in () do (set /p "data=" && echo(!date! !time! !data!)&ping -n 2 localhost>nul" > log.log
In the example above the script will ping the address 192.168.1.31 continuously. It will add date and time stamps and save the output to a file called log.log.
The output file will be saved in the same directory the batch script is run from.
If you found this useful you may also be insterested in 12 CCTV Resources that Actually Add Value.
Leave a Reply