batch to check if a file is saved every 15 mins

January 28, 2013 at 07:20:48
Specs: Windows 7
Hi, I need a batch file to check if a file is saved every 15 mins from 9am to 5pm, if not, send an email to alert me. Thanks in advance, i am new to batch..

See More: batch to check if a file is saved every 15 mins

Report •

#1
January 28, 2013 at 11:54:38
maybe like this:
::===== begin batch
@echo off & setlocal
set text=file update failure:
:loop
if not exist filename (
set text=file not found at
goto :alert
)

for %%a in (filename) do set this=%%~ta
if not defined last goto :next

:alert
if %last% equ %this% (
>alert echo %text%%time%
blat alert -to someone@somewhere -u loginid -pw passwd
)
:next
set last=%this%
timeout 900
goto :loop
::======= end (not tested)
(Oops! edit to fix my jack-up: for /f)
Or you could use schtasks or "at" to set up a 15-minute cycle for running the checker, but the checker would need to store the previous file-time (%last%) in a file or use a global variable to hold it between runs (since it would shut down after each run). I used blat for the email, but there are of course numerous options (including vbscript if you want "native" but I recommend blat). Timeout being win-7 only, if you want to run on xp you could use ping.


Report •
Related Solutions


Ask Question