How do I check whether or not a scheuled task is currently running?

Is there a way to see if a task is currently executing? I need a process to run to completion and not get retriggered until it completes successfully.

Use an exclusive named lock?


This could be as simple as checking for the existence of a file on the file system.

At the beginning of the code running the task:

var runTask = false;

if( fileExists( myFile ) ) {
    fileDelete( myFile );
    runTask = true;

if( runTask ) {

    // run your task code


Wherever in the code you want to mark the task as having been completed:

fileWrite( myFile, now() );

This checks for the file before running the task specific code, if it finds the file it deletes it from the file system and sets a flag to run your task code that you can check. If it doesn’t find the file, then your task had not completed before this retrigger and your code is not run.

Adding the file at the completion of your task code lets you know if it ran to completion during each retrigger.

You could just as easily do the reverse… write the file when the task is triggered and remove it upon completion… then you will know that the task is still running so long as the file remains on the system. Half dozen of one, six of the other.


– Denny

I had hoped there would be a system level “isRunning” flag or something, but these are both reasonable workarounds. Thank you.