+ Reply to Thread
Results 1 to 4 of 4

Thread: job chaining

  1. #1
    climater is offline Junior Member
    Join Date
    January 21st, 2009
    Posts
    1
    Downloads
    0
    Uploads
    0

    Question job chaining

    Hello,

    I want to run a series of chained jobs, namely the second job will start when the first job is done, the third job will start when the second is done, and so on. I understand I can take advantage job dependencies by using the "bsub -w" option. But since the number of jobs is no small, I prefer using a shell script to do job submission. And my question is how to pass the job id of the previous job to the submission command of the next job in a shell script.

    Thank you!
    David

  2. #2
    gthomas is offline Junior Member
    Join Date
    February 29th, 2008
    Posts
    14
    Downloads
    2
    Uploads
    0

    Default

    You can use jobnames instead of jobids, so in that case u can just have a script that names each jobs as job1, job2 etc ...
    Speeding does not kill. Staying stationary does.

  3. #3
    RhodeKille is offline Junior Member
    Join Date
    September 23rd, 2008
    Posts
    2
    Downloads
    0
    Uploads
    0

    Default

    You could also parse the output from the bsub command to get the jobID, and use that in the subsequent bsub calls.

    Something like:
    jobid=`bsub .... | sed "s/.*<\([0-9]*\)>.*/\1/"`

  4. #4
    csmith's Avatar
    csmith is offline Junior Member
    Join Date
    March 20th, 2008
    Posts
    26
    Blog Entries
    7
    Downloads
    17
    Uploads
    1

    Default

    If you're going to use job ids, you have to make sure and deal with a possible race condition where the first job starts changing state before your dependent job has been submitted. You can avoid this by submitting the first job with a hold, and then resume it after the dependent job(s) has been submitted.

    Here's a /bin/sh script fragment that I've used in the past:

    #!/bin/sh

    jobid=`bsub -H -o /dev/null sleep 30 | awk '{print $2}'|sed -e 's/[<>]//g'`
    bsub -o /dev/null -w "done($jobid)" sleep 30
    bresume $jobid

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts