Hi Hector,
begin multicommand
create or alter named resource RESOURCE.TEMPLATES with usage = CATEGORY;
create or alter named resource RESOURCE.TEMPLATES.BATCHLOCK with usage = SYNCHRONIZING;
create or alter folder SYSTEM.TEMPLATES;
create or alter folder SYSTEM.TEMPLATES.SKIP_IF_RUNNING;
create or alter resource RESOURCE.TEMPLATES.BATCHLOCK in SYSTEM.TEMPLATES.SKIP_IF_RUNNING with online;
create or alter job definition SYSTEM.TEMPLATES.SKIP_IF_RUNNING.LOCK
with
environment = 'SERVER@LOCALHOST',
profile = 'STANDARD',
run program = '0',
resource = ( RESOURCE.TEMPLATES.BATCHLOCK STICKY lockmode = X ),
timeout = 0 MINUTE state 'SKIPPED',
type = JOB;
create or alter job definition SYSTEM.TEMPLATES.SKIP_IF_RUNNING.MAIN
with
profile = 'STANDARD',
type = BATCH,
required = ( SYSTEM.TEMPLATES.SKIP_IF_RUNNING.LOCK state = ALL REACHABLE);
create or alter job definition SYSTEM.TEMPLATES.SKIP_IF_RUNNING.UNLOCK
with
environment = 'SERVER@LOCALHOST',
profile = 'STANDARD',
run program = '0',
resource = ( RESOURCE.TEMPLATES.BATCHLOCK STICKY lockmode = X),
type = JOB,
required = ( SYSTEM.TEMPLATES.SKIP_IF_RUNNING.MAIN state = ALL REACHABLE);
create or alter job definition SYSTEM.TEMPLATES.SKIP_IF_RUNNING.SKIP_IF_RUNNING
with
profile = 'STANDARD',
type = BATCH,
master,
children = (
SYSTEM.'TEMPLATES'.'SKIP_IF_RUNNING'.'LOCK',
SYSTEM.'TEMPLATES'.'SKIP_IF_RUNNING'.'MAIN',
SYSTEM.'TEMPLATES'.'SKIP_IF_RUNNING'.'UNLOCK'
);
end multicommand;
After running the above script you can now use the template as follows.