need a batch file to run tracert once per h

February 9, 2011 at 20:00:37
Specs: Windows XP
Hey guys,
Im having isp problems with lost packets, and I need a batch file to exec tracert once per hour or so all day and create a log of its findings. Can someone help me?
thanks
nub

See More: need a batch file to run tracert once per h

Report •


#1
February 9, 2011 at 20:23:14
@echo off

:start
PING 1.1.1.1 -n 1 -w 3600000 >NUL
your code

goto start


this code should wait a hour before running again. Let me know if you have any problems


Report •

#2
February 10, 2011 at 05:29:12
rem "Output is saved in this path D:\Monitoring"
rem "this will run every hour"
rem "change the ipaddress 172.16.71.46 in the code"

@ ECHO OFF

rem US date
set YEAR=%DATE:~10,4%
set MONTH=%DATE:~4,2%
set DAY=%DATE:~7,2%

cd\
d:
md Monitoring
cd Monitoring

md %YEAR%%MONTH%%DAY%
cd %YEAR%%MONTH%%DAY%

echo ------------------------------------------------------------------------------------------- >> Log%YEAR%%MONTH%%DAY%.txt
echo SERVER TIMESTAMP STATUS >> Log%YEAR%%MONTH%%DAY%.txt
echo ------------------------------------------------------------------------------------------- >> Log%YEAR%%MONTH%%DAY%.txt
:START

set HOUR=%TIME:~0,2%
set MIN=%TIME:~3,2%
set SEC=%TIME:~6,2%
set HUNDREDS=%TIME:~9,2%
set HOURMIN=%HOUR%%MIN%

rem Make shure that hour has two digits
IF %HOUR% GEQ 10 goto twoh
set HOUR1=%TIME:~1,1%
set TWOHOUR=0%HOUR1%
goto fulltid

:twoh
set TWOHOUR=%HOUR%

:fulltid
set FULLTIME=%TWOHOUR%'%MIN%'%SEC%'%HUNDREDS%
set FTIME=%TWOHOUR%:%MIN%:%SEC%

ping 172.16.71.46 > d:\Monitoring\%YEAR%%MONTH%%DAY%\Ping_%YEAR%%MONTH%%DAY%_%FULLTIME%.txt
tracert 172.16.71.46 > d:\Monitoring\%YEAR%%MONTH%%DAY%\Tracert_%YEAR%%MONTH%%DAY%_%FULLTIME%.txt

@echo off & setLocal EnableDELAYedeXpansion
echo on
for /f "tokens=4,7 delims=, " %%a in ('ping 172.16.71.46 ^| find "loss"') do (
IF %%a neq %%b (
echo 172.16.71.46 %FTIME% Failure >> Log%YEAR%%MONTH%%DAY%.txt
) ELSE (
echo 172.16.71.46 %FTIME% Success >> Log%YEAR%%MONTH%%DAY%.txt
)
)

sleep 60
goto START


Report •

#3
February 10, 2011 at 05:43:01
The Windows 2003 Resource Kit includes a "sleep" command (as well as many other useful tools). This is the most efficient way of pausing as it will be using no processor time whilst waiting.

Report •

Related Solutions

#4
February 10, 2011 at 05:45:09
To use the sleep command in the above code u need

"Windows Server 2003 Resource Kit Tools"
download it from

http://technet.microsoft.com/en-us/...

then
Save the above code with some name.cmd or name.bat
the above code generates three logs every hour..
in the folder D:\Monitoring\20110210
you will get the output in this format in a logfile "Log20110210.txt"

----------------------------------------------------------
SERVER TIMESTAMP STATUS
---------------------------------------------------------
172.16.71.46 19:11:34 Success

You will also get log file of ping and tracert as follows
Ping_20110210_19'11'34'96.txt

Pinging 172.16.71.46 with 32 bytes of data:
Reply from 172.16.71.46: bytes=32 time<1ms TTL=127
Reply from 172.16.71.46: bytes=32 time<1ms TTL=127
Reply from 172.16.71.46: bytes=32 time<1ms TTL=127
Reply from 172.16.71.46: bytes=32 time=1ms TTL=127
Ping statistics for 172.16.71.46:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms

Tracert_20110210_19'11'34'96.txt


Tracing route to 172.16.71.46 over a maximum of 30 hops
1 <1 ms <1 ms 1 ms 172.16.69.2
2 <1 ms <1 ms <1 ms 172.16.71.46
Trace complete.


Report •

#5
February 10, 2011 at 15:16:43
@echo off
echo wscript.sleep 3600000 >%temp%\slep.vbs
:start
your code
cscript /nologo %temp%\slep.vbs
goto start


It will wait for 1 hr before next loop and will not use cpu time

Subhash Chandra.
www.s-chandra.co.cc


Report •

Ask Question