check last modified date & time with current date & time and if file is stagnate for more than 10 min take actin in batch

what would be the simplest way in a batch file to check the modified date and time of a specified file and take a specific action if its more than 10 min old?

@echo off
echo 3
ping -n 2>nul
echo 2
ping -n 2>nul
echo 1
ping -n 2>nul
echo logfile is not older than 10 min
) || (
echo attempting to restart
net stop log2
net start log2
goto loop
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Since there's no built-in command line tool to compare dates, here's a batch script that creates a VB script on the fly that does the date calculation:
@echo off
setlocal enabledelayedexpansion
set LogFile=D:\Temp\test.log
set MaxAge=1
set Service=log2

set VbsFile=%Temp%\DateDiff.vbs
call :ExportDataSection VBS "%VbsFile%"
cscript.exe //nologo "%VbsFile%"
if errorlevel 1 (
	echo [%Time%] File older than %MaxAge% minutes.
	net.exe stop "%Service%"
	net.exe start "%Service%"
) else (
	echo [%Time%] File current.
ping.exe -4 -n 21 localhost >NUL
goto Loop

REM ================================================================================
REM Only functions after this line!
REM ================================================================================
goto :eof
REM *** Reads all lines listed in %1 (section) and writes them to %2 (file name).
REM *** Environment variables will be expanded.
set Section=%~1
set FileName=%~2
if exist "%FileName%" del "%FileName%"
for /f "tokens=1 delims=[]" %%a in ('type "%~f0" ^| C:\Windows\system32\find.exe /n "[%Section%]"') do set DataStart=%%a
for /f "skip=%DataStart% delims=" %%a in ('type "%~f0"') do (
	call :Expand Line "%%a"
	if "!Line:~0,1!"=="[" (goto :eof) else (>>"%FileName%" echo !Line!)
goto :eof

set %1=%~2
goto :eof

REM ================================================================================
REM Only data sections after this line!
REM ================================================================================
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.getFile("%LogFile%")
If DateDiff("n", objFile.DateLastModified, Now) > %MaxAge% Then
	intErrorLevel = 1
	intErrorLevel = 0
End If

Open in new window

NVITEnd-user supportCommented:
Do you want a pure .bat solution?

How about a command line utility like WasFile, which:
...compares ...time&date of a file with now-n (minutes)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
csePixelatedAuthor Commented:
oBdA I appreciate the input, but i really am looking for the simple solution, i wish i could undoo and give you 100 as i really appreciate the script.
NVITEnd-user supportCommented:

You can adjust the points. Pick Request Attention at the bottom right of your original post. Submit your reason.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.