• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Ulrich's TechLib

Electronic Security Library & Other Oddities

  • HOME
  • BLOG
  • ABOUT
  • PRIVACY POLICY
  • CONTACT
You are here: Home / Networks / Ping to Log File With a Timestamp

Ping to Log File With a Timestamp

Jun 11, 2020 by Ulrich Leave a Comment

Ping with timestamp to a log file

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.

@echo off
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.

Share

Share
Share
Tweet

Filed Under: Networks Tagged With: batch script, log, ping, timestamp

Reader Interactions

Leave a Reply Cancel reply

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

Footer

Get Social

  • Facebook
  • LinkedIn
  • Twitter

Post Tags

acc acc 5 acc 6 acc 7 acc client acc server password alarm anydesk avigilon avigilon directory backup batch script cctv create pop-up google earth internet log lucidchart obs studio onvif device manager password ping pop-up pop-up alarm port-forwarding port forwarding putty server teamviewer timestamp upgrade video analytics vlc

Site Archives

  • Aug 2020
  • Jul 2020
  • Jun 2020

Newsletter

Copyright © 2022 ยท Ulrich's TechLib