Batch job2 automatically runs upon the completion of batch job1

Baijumon Mani 0 Reputation points
2024-03-27T15:16:54.5066667+00:00

is there a way to set up a scenario in which batch job 2 automatically runs upon the completion of batch job 1 in the Windows task scheduler?

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,458 questions
Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,371 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 48,281 Reputation points
    2024-03-27T17:36:50.44+00:00

    Couple of options come to mind.

    1. Create a master batch/PS script that runs the first job and then the second job. This gives you the most flexibility in that you can control when, if ever, the second job should run. This is probably how I'd do it.
    2. Add both jobs to the same task as separate actions. The scheduler runs the actions sequentially and this has been a recommended approach for a while. But some caveats here as I've never actually done it this way. Firstly, the second action doesn't run until the first action completes, based upon observations, but this isn't documented anywhere. Secondly, the second action is going to run irrelevant of the first action's results. If you need to run the second job only if the first completes then you'll have to implement some sort of solution that allows for this detection.

  2. Jing Zhou 2,085 Reputation points Microsoft Vendor
    2024-03-28T08:49:58.1433333+00:00

    Hello,

    Thank you for posting in Q&A forum.

    In the Windows Task Planner, you can set a batch job trigger to automatically run batch job 2 after batch job 1 is completed. To achieve this, you need to:

    Open the Task Planner (by searching for "Task Planner" in the Start menu).

    Create task for batch job 1.

    When creating a task, select the "Triggers" tab, then add a trigger, select the "When Existing Jobs Complete" option, and select Batch Job 1.

    Create a task for batch job 2 and set the trigger to complete batch job 1.

    After this setting, when batch job 1 is completed, batch job 2 will automatically run.

    Hope this answer can help you well.

    Best regards,

    Jill Zhou