0

I'm looking for some direction in scheduling sequential tasks within Windows Scheduler. The tasks in this instance are workflows that kick off data ETL and incremental load jobs. We want to only initiate subsequent tasks in which prior tasks have been finished. Any help would be greatly appreciated.

Thanks!!

3 Answers 3

1

If you're familiar with the linux world, it's done by joining multiple commands with &&, which waits until SUCCESSFUL completion of the first job before starting the second (and aborts if the first job fails). Windows finally added it to cmd.exe. So...

You can bundle your tasks into a .bat file one-liner with the individual tasks seperated by &&. I do a weekly reboot with the following command where I suspend a VM before doing a shutdown /r. Works great.

C:\Users\JohnB>type reboot.bat
"c:\program files (x86)\vmware\vmware player\vmrun" -T player suspend g:\VMWare\kali-linux-2022.4-vmware-amd64.vmwarevm\kali-linux-2022.4-vmware-amd64.vmx && shutdown /r /t 0
0

You can create a multi-step task in Windows Task Scheduler, but all steps will run when the task triggers. (You can use Start /Wait ... to get each step to wait until finished before handing off to the next step, if that's all you need. But if you need to abort the whole set if one step fails, you'll need more granularity than Task Scheduler.)

Your other option is to make the Windows Task Scheduler kick off a single batch file or Powershell script that will then handle the rest. The batch file or Powershell script can then kick off your first task, wait for the result, and then decide what to do next.

3
  • Thanks Dog for your response!! I have another slight nuanced scenario. So we have two parallel tasks running and then we have a child tasks that is DEPENDENT on both the parallel tasks completing. How would you configure something like that? And also for future scenarios in which there could be 3,4 parallel parent tasks that future tasks will depend on. Thanks for your help.
    – Whit
    Jan 31, 2019 at 21:32
  • If running the tasks in series is an option, you can use Start /Wait ... for that. But if they have to run in parallel, and a future task has to be delayed until both parallel tasks finish, you'll want to use something with more flexibility than the Windows Task Scheduler. A batch file or PowerShell script can start the parallel tasks, keep track of their successes or failures, and then decide if and when to start the following task or tasks.
    – Doug Deden
    Jan 31, 2019 at 22:44
  • the whole point of allowing Task Scheduler to handle the actions for you is that you have some more control should one of the actions freeze or otherwise be unable to complete an action timely. And you can log which actions were completed ok. Batch file can work for simple actions, but more complex, sequential or other event-driven triggers, batch command becomes more tricky.
    – Jon Grah
    Aug 6, 2022 at 12:13
0

Apparently, when you add several actions to a single task, they are executed sequentially, instead of simultaneously. At least this was my experience. When I tested using cmd.exe /c ping google.com as a first action and cmd.exe /c ping apple.com as a second one, running the task made the second cmd window appear only after the first one closed.

So, if you have a case of two or more sequential tasks with the same settings that must be always executed together, you can set them up as different actions in a single task.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .