Solved Check if my batch job is running and do some operations?

August 14, 2017 at 17:20:57
Specs: Windows, 6
I want to check if my batch job is running beyond 1 hr and if that is the case notify me else start the next round of batch job.

My script is scheduled to run every 1 where I am extracting user information based on some condition and emailing users certain information. I am running this every hour


See More: Check if my batch job is running and do some operations?

Reply ↓  Report •

#1
August 15, 2017 at 09:17:49
✔ Best Answer
Traditionally, you'd use a lock file, and that'd tell you if your script is either still running, or previously errored out. Something like this:

SET lock="%temp%\%~n0.lock"
IF EXIST %lock% GOTO errorOut
COPY NUL %lock%

REM Your code here

REM Normal exit
DEL %lock%
GOTO :EOF

:errorOut
REM Your error notification stuff here

How To Ask Questions The Smart Way

message edited by Razor2.3


Reply ↓  Report •

#2
August 15, 2017 at 11:06:13
Thanks for the quick reply Razor. It really helped.
Thanks

Reply ↓  Report •
Related Solutions


Ask Question