Skip to content

Instantly share code, notes, and snippets.

@uuklanger
Created December 24, 2016 06:20
Show Gist options
  • Save uuklanger/757250d9c8e688455312ba0f4bfd916a to your computer and use it in GitHub Desktop.
Save uuklanger/757250d9c8e688455312ba0f4bfd916a to your computer and use it in GitHub Desktop.
@echo off
REM
REM Example of howto use a lockfile in BATCH language
REM
:INIT
CD \BatchJobs
ECHO Current Working Directory
CD
:START
IF EXIST NIGHTLYRUN.LOCK GOTO SKIP_WORK
ECHO Turning on Lock
ECHO ""LOCK"" > NIGHTLYRUN.LOCK
REM Do work here. this is where your program or process goes.
ECHO Turning off Lock
DEL NIGHTLYRUN.LOCK
GOTO DONE
:SKIP_WORK
ECHO ""This process is already running..""
:DONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment