Batch process creating other batch processes

I have a batch class that when executed, creates a number of batch processes using BatchHeader functionality. The main batch (MP) runs every hour and creates 5-8 child batch processes (TP). These run and then the next hour, the process starts again. This works fine when everything executes by the schedule. My problem is that when something delays the launch of the main batch process (MP), when it finally does start, it will try and run multiple times in a row. This creates a lot of the child batch processes and not only slows the system to a crawl, but can causing locking problems on the table it is updating.

Is there a way to modify the main batch process to have it wait until all the child batches it has created, have finished running?

Thanks,

Shawn

Can’t you simply create jobruntime batch tasks belonging to the “main” batch, instead of creating additional top-level batch jobs? If you use tasks, the batch job won’t be considered completed until all tasks finish and therefore won’t run again until then.

Martin, Thank you for your quick reply .

The reason the main batch process kicks off the other batches is what it does first. The main process reads a number of records from a table and marks a field in that record with a number and then saves it. When it kicks off a child batch it passes that number to the child batch so it will only process records with that number. This is due to when we tried to run this process before we had locking on the main table that each process uses and bad data.

Are you saying I can add the other batches to the batch the main task is running in and then the main batch will be done when all the child batches are done?

Thanks,
Shawn

Here you can see an example of what I mean: Adding runtime tasks to a business operation framework service.

Martin,

This was exactly what I needed. Thanks you very much.

Regards,
Shawn