

InterviewSolution
Saved Bookmarks
1. |
Solve : Check to see if file is 15min or older than current time.? |
Answer» <html><body><p>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)<br/>echo off<br/>c:\find\find.exe c:\yms -type f -mmin +0 -mmin -2 -print > c:\yms\timeresult.txt<br/>echo errorlevel is %errorlevel%<br/>find "schedok.txt" c:\yms\timeresult.txt<br/>echo errorlevel2 is %errorlevel%<br/>pause<br/><br/>If the file name is in the txt file then I can end. If not send out pages.<br/><br/>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 <a href="https://interviewquestions.tuteehub.com/tag/someone-25657" style="font-weight:bold;" target="_blank" title="Click to know more about SOMEONE">SOMEONE</a> 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.<br/><br/><br/>*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.<br/><br/>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.<br/><br/>This should avoid the need for a intermediate file:<br/><br/> Code: <a>[Select]</a>c:\find\find.exe C:\yms -type f -mmin +0 -mmin -2 | findstr "schedok.txt">nul && goto end<br/>REM code to run if file not found<br/>:end<br/><br/><br/> Quote</p><blockquote>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. </blockquote> <br/>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 <a href="https://interviewquestions.tuteehub.com/tag/present-1163722" style="font-weight:bold;" target="_blank" title="Click to know more about PRESENT">PRESENT</a> instant, back to Y minutes ago. In other <a href="https://interviewquestions.tuteehub.com/tag/words-25841" style="font-weight:bold;" target="_blank" title="Click to know more about WORDS">WORDS</a> 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) <em>-mmin +0 -mmin -2</em> is equivalent to <em>-mmin -2</em> i.e. -mmin +0 is superfluous?<br/><br/>I have tested this and found that putting just -mmin -1 will find a file 2 seconds old.<br/><br/>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.<br/><br/> Code: <a>[Select]</a>C:\>echo %time% & gnu-find.exe T:\timelog -type f -mmin -1 | findstr "MyTimeLog"<br/> 9:17:52.43<br/>T:\timelog/MyTimeLog-09-17-50-98.txtwell here is the final script that is running in production. It tested pretty well. At the <a href="https://interviewquestions.tuteehub.com/tag/moment-25786" style="font-weight:bold;" target="_blank" title="Click to know more about MOMENT">MOMENT</a> I'm the only one it pages so if it goofs I'll be the only one getting the pages<br/><br/> Code: <a>[Select]</a>echo off<br/>::<a href="https://interviewquestions.tuteehub.com/tag/check-25817" style="font-weight:bold;" target="_blank" title="Click to know more about CHECK">CHECK</a> scheduler status.<br/>:checktime<br/>Ufind.exe c:\timecheck -type f -mmin +0 -mmin -30 | findstr "servertest.csv" >nul && goto end<br/>echo %date% %time% "sending message" >> schedlog.txt<br/>mailsend1 -d yourdomain.com -smtp yourdomain.com -port 25 -starttls -v -f <a href="/cdn-cgi/l/email-protection">[email protected]</a> +cc +bc -auth-login -user <a href="/cdn-cgi/l/email-protection">[email protected]</a> -pass "yourpassword" -t <a href="/cdn-cgi/l/email-protection">[email protected]</a> -sub "Check system scheduler" -M "Scheduler has stopped for more that 30min"<br/>echo "text sent to user" >> schedlog.txt<br/>::wait 5 min and try again<br/>ping 127.0.0.1 -n 300 >NUL<br/>goto checktime<br/>:end<br/>::Do not send txt<br/>exit<br/>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.<br/><br/>I hope this helps someone else stuck in the same bind.<br/><br/>thanks again Salmon Trout!</body></html> | |