1.

Solve : Check to see if file is 15min or older than current time.?

Answer»

looks like we were thinking the same thing just going about it differently  This is what I came up with (although your solution is more elegant)
echo off
c:\find\find.exe c:\yms -type f -mmin +0 -mmin -2 -print  > c:\yms\timeresult.txt
echo errorlevel is %errorlevel%
find "schedok.txt" c:\yms\timeresult.txt
echo errorlevel2 is %errorlevel%
pause

If the file name is in the txt file then I can end.  If not send out pages.

As for the zero I saw that if i did a min +1 it waited for the first 59sec to elapse before being seen thus giving me a false positive.  Granted it's a small window but I will close it if i can.  I'm gonna put your version in and start testing.  Once It works I'll post up the entire working script with mail commands just in case SOMEONE else has the same problem.  It took a little work to get the mailsend command to work with appriver hosted exchange.  It might same someone some time.


*edit* ok it looks like it is working.  I have to wait till the weekend till i can put it into production and then run some tests.  Will post up finished code when it works.

thanks again for the help.I think your method of looking for the actual time log file name is better. Less chance of a false result, should find.exe output an error message.

This should avoid the need for a intermediate file:

Code: [Select]c:\find\find.exe C:\yms -type f -mmin +0 -mmin -2 | findstr "schedok.txt">nul && goto end
REM code to run if file not found
:end


Quote

As for the zero I saw that if i did a min +1 it waited for the first 59sec to elapse before being seen thus giving me a false positive.

What I meant was, if you use the -mmin +X -mmin -Y format you are specifying a time range: modified at least X minutes ago and not more than Y minutes ago. If you just use -mmin -Y you are going to catch any file modified from now, the PRESENT instant, back to Y minutes ago. In other WORDS if you just specify the "minus" ("not earlier than") time, the start of the looking-backwards time range is implicitly "right now". So that (surely)  -mmin +0 -mmin -2 is equivalent to -mmin -2 i.e. -mmin +0 is superfluous?

I have tested this and found that putting just -mmin -1 will find a file 2 seconds old.

Here it finds a file which was modified 2.45 seconds before. You will see I have renamed the GNU find.exe because like many people I deplore the idea of having 2 different executables, one native, one third party, with the same (common) name.

Code: [Select]C:\>echo %time% & gnu-find.exe T:\timelog -type f -mmin -1 | findstr "MyTimeLog"
 9:17:52.43
T:\timelog/MyTimeLog-09-17-50-98.txtwell here is the final script that is running in production.  It tested pretty well.  At the MOMENT I'm the only one it pages so if it goofs I'll be the only one getting the pages

Code: [Select]echo off
::CHECK scheduler status.
:checktime
Ufind.exe c:\timecheck -type f -mmin +0 -mmin -30 | findstr "servertest.csv" >nul && goto end
echo %date% %time% "sending message" >> schedlog.txt
mailsend1 -d yourdomain.com -smtp yourdomain.com -port 25 -starttls -v -f [email protected] +cc +bc -auth-login -user [email protected] -pass "yourpassword" -t [email protected] -sub "Check system scheduler" -M "Scheduler has stopped for more that 30min"
echo "text sent to user" >> schedlog.txt
::wait 5 min and try again
ping 127.0.0.1 -n 300 >NUL
goto checktime
:end
::Do not send txt
exit
I changed the unix find command to ufind and put it in the system32 directory along with mailsend1 (latest version of mailsend)  I added the looping so that i would get pages every 5 min.  In windows scheduler I put that if the program has been running longer than 25min to stop it.  I run it through the scheduler every 1/2 hour.

I hope this helps someone else stuck in the same bind.

thanks again Salmon Trout!


Discussion

No Comment Found