none
How do I ensure submitted jobs run one after another? RRS feed

  • Question

  • Hello All,

     

    I am trying to run a program through GUI.  The gui calls scripts for preprocessor and solver, one after the other.  In the preprocessor script I have "job submit.....".  This returns control immediately to the solver part.  The solver however needs output files from the preprocessor to begin.  Any ideas on how to make this work in sequence?

     

    Thanks,

    Anup.

    Tuesday, April 15, 2008 11:00 PM

Answers

  •  

    Anup,

    The scheduler is designed to handle exactly this type of thing, but rather than using Jobs, it is designed to do is using Tasks.

     

    Each job can be made of multiple tasks, and these tasks can have dependencies between them (run this task only after this other task is done).

     

    So for you, what I would recommend doing is creating a Pre-Processing Task, an Execution Task, and a Post-Processing task.  If you look online for the v1 documentation, it should include some details on this.  It would work something like

     

    Job new /name:"My Job"

    Job add /name:"Pre-processing task" filecopy.cmd

    Job add /name:"Execution task" execute.exe

    Job add /name:"Post-processing task" cleanup.cmd

    Job submit 12

     

    Thanks,
    Josh

    Wednesday, April 16, 2008 6:41 AM
    Moderator
  •  

    Anup,

    http://technet2.microsoft.com/WindowsServer/en/Library/e544d9e2-e1db-447c-8a31-6bd0c30d809c1033.mspx

     

    The above link is to the v1 Command Line reference which should explain how to do everything.

     

    As a quick example, to create a job with two tasks, "First Task" and "Second Task" which run in order (i.e. NOT in parallel) you could do the following:

     

    Code Snippet

    C:\Users\JBarnard>job new /jobname:"Two-Task Job" /numprocessors:1
    Created job, ID: 39

    C:\Users\JBarnard>job add 39 /name:"First Task" mkdir example
    Task 39.1 added.

    C:\Users\JBarnard>job add 39 /name:"Second Task" /depend:"First Task" rmdir /q example
    Task 39.2 added.

    C:\Users\JBarnard>job submit /id:39
    Enter the password for 'REDMOND\jbarnard' to connect to 'JBARNARDHN':*************
    Remember this password? (Y/N)Y
    Job had been submitted. ID: 39.

     

    I created a job, added a task which created a directory called "Example", added a task which deleted an directory called "Example" (this task depended on the first task being completed before it could start), and then submitted the job to the system.

     

    Thanks,
    Josh

    Monday, April 28, 2008 6:40 PM
    Moderator

All replies

  •  

    Anup,

    The scheduler is designed to handle exactly this type of thing, but rather than using Jobs, it is designed to do is using Tasks.

     

    Each job can be made of multiple tasks, and these tasks can have dependencies between them (run this task only after this other task is done).

     

    So for you, what I would recommend doing is creating a Pre-Processing Task, an Execution Task, and a Post-Processing task.  If you look online for the v1 documentation, it should include some details on this.  It would work something like

     

    Job new /name:"My Job"

    Job add /name:"Pre-processing task" filecopy.cmd

    Job add /name:"Execution task" execute.exe

    Job add /name:"Post-processing task" cleanup.cmd

    Job submit 12

     

    Thanks,
    Josh

    Wednesday, April 16, 2008 6:41 AM
    Moderator
  • Thanks Josh.

     

    I tried your suggestion.  It didn't work.  Maybe I'm doing something wrong.

     

    As soon as I issue : Job new /name:"My Job" it places the job into the job queue with a system generated job id (How do I get this job id? Is there an environment variable associated with this id?).  When I do :Job add /name:"Pre-processing task" filecopy.cmd, I was assuming it would add it to the new job I created, but I can't see it anywhere. 

     

    Is there a document on-line that would give me some examples that I could follow?  I tried searching but couldn't find one that I'm, looking for.

     

    Thanks for your help.

    Regards,

    Anup.

    Thursday, April 17, 2008 7:20 PM
  •  

    Anup,

    http://technet2.microsoft.com/WindowsServer/en/Library/e544d9e2-e1db-447c-8a31-6bd0c30d809c1033.mspx

     

    The above link is to the v1 Command Line reference which should explain how to do everything.

     

    As a quick example, to create a job with two tasks, "First Task" and "Second Task" which run in order (i.e. NOT in parallel) you could do the following:

     

    Code Snippet

    C:\Users\JBarnard>job new /jobname:"Two-Task Job" /numprocessors:1
    Created job, ID: 39

    C:\Users\JBarnard>job add 39 /name:"First Task" mkdir example
    Task 39.1 added.

    C:\Users\JBarnard>job add 39 /name:"Second Task" /depend:"First Task" rmdir /q example
    Task 39.2 added.

    C:\Users\JBarnard>job submit /id:39
    Enter the password for 'REDMOND\jbarnard' to connect to 'JBARNARDHN':*************
    Remember this password? (Y/N)Y
    Job had been submitted. ID: 39.

     

    I created a job, added a task which created a directory called "Example", added a task which deleted an directory called "Example" (this task depended on the first task being completed before it could start), and then submitted the job to the system.

     

    Thanks,
    Josh

    Monday, April 28, 2008 6:40 PM
    Moderator