[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] 24x7 Script Archive


Preventing jobs from the same "class" to run simultaneously

Q: Is it possible to create job "class" and to define that two jobs from one "class" lets say "Class A" can not start at the same moment?

A: Use global variables to implement such "class" type semaphores. Every job from the same class on startup should set the appropriate global variable to some known value like "active" and then before exit reset the variable.

Use the following code fragment as a template

Dim global.class_A, string
Dim busy, boolean
Dim process, number

// check flag
isEqual( global.class_A, "active", busy )
// if busy (another job from the same class is running) don't run now
IfThen( busy, DONE )
      // ok, can run now
      // raise flag
   Set( global.class_A, "active" )
   // run program
   RunAndWait( "myprogram.exe, "", 300, process )
   // reset flag
  Set( global.class_A, "inactive" )
DONE: