I want to schedule 4 task on windows task schedular.

The conditions are

1. Task 1 should run every 30 mins;
2. Task 2 should run every 1 hour;
3. Task 3 should run every 2 hours;
4. Task 4 should run every 3 hours;
5. None of the 2 task should run at the same time;
6. If error comes in any task it should run again next time;
7. Also, I don't want to maintain any file regarding it. 

Thanks in advance.

Additional Details:
Note: For each day we have millions of records.
So completing of each task varies from 30 mins to around 1 hour.

Task 1: Gets data for 0-7 Days, updates it and then saves back to the sql server.
Similarly task 2,3, and 4 does it for 0-14,0-21 and 0-31 days.

Now the problem is with the server that it is single login, i.e if task 2 logins then task 1 is logged out. I don't have any control on the sql server (3rd party).

So a sample of how the task should run is like this

00:00 Task 1 Starts
00:20 Task 1 Completes
00:30 Task 1 Starts
01:00 Task 2 Waiting to start
01:05 Task 1 Completes
01:05 Task 2 Starts
01:30 Task 1 Waiting to start
01:45 Task 2 Completes
01:45 Task 1 Starts
02:00 Task 3 Waiting to start
02:10 Task 1 Completes
02:10 Task 3 Starts
02:30 Task 1 Waiting to start
03:00 Task 4 Waiting to start (Since task 4 already contains task 1, so the waiting task 1 should call off itself)
03:05 Task 3 Completes
03:05 Task 4 Starts
and so on...
  • What OS are you using? For instance, server 2008 and above have a vastly improved task scheduler to 2003, if I know what OS you're running I may be able to be of more help. – Alex Berry Aug 4 '14 at 13:00
  • I m using server 2008. I just want to know how to put dependency among independent task scheduled. – PuranJoshi Aug 4 '14 at 15:21
  • I don't think task schedule can directly have dependencies, but whatever scripts your running could include something along these lines at the beginning: – Alex Berry Aug 4 '14 at 15:36
  • I don't think task schedule can directly have dependencies, but whatever scripts your running could include something along these lines at the beginning: schtasks /query /TN \Microsoft\Windows\Wininet\CacheTask Where "/TN" is the task name and the line following is the location of the task. This will tell you if something's running, if you can parse the output in a script and then have the script wait until "status" changes from "Running" to "Ready" then you could go from there. – Alex Berry Aug 4 '14 at 15:36
  • I know this won't help very much, but this would be oh-so-very-much-easier in bash than batch file. You might want to try a powershell script, but I'm not as competent with it as I am with bash. – Alex Berry Aug 4 '14 at 15:45

task 1 start time: 00:00

task 2 start time: 00:01 (depending on how long task 1 takes to run).

task 3 start time: 00:02 (depending on how long task 2 takes to run).

task 4 start time: 00:03 (depending on how long task 3 takes to run).

That would take care of the overlap, for step number 6, task scheduler shouldn't abort the next attempt if there's an error by default so you're OK there. With regards to maintaining any files, I can't help unless you're more specific about what this task does, it it just runs a script that doesn't write anywhere then there should be nothing to maintain, if it's writing logs or data you want to keep then you need to build a script to manage that data (probably).

If you want a more thorough answer you will have to provide a lot more information, such as what your tasks do, what OS you're running etc.

  • Thanks... Please check the edited question for more details – PuranJoshi Aug 4 '14 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.