0

I have an issue to saye for the job1 to wait job2 dynamically wiht variable name in LSF,here is my code

#!/bin/bash

JOB1=first
JOB2=second

bsub -I -q reg -J $JOB1 "ls /bin*" &
bsub -I -q reg -w 'done("$JOB1")' -J $JOB2 ls /usr/ &"
shellter
  • 36,525
  • 7
  • 83
  • 90

1 Answers1

1

A couple of guesses.

  1. bash won't expand a variable that is inside single quotes. You probably meant this

    bsub -I -q reg -w "done($JOB1)" -J $JOB2 "ls /usr/ &"
    
  2. LSF may not know about the first job when the second job is submitted. Since the first bsub is run in the background, both bsubs "race" each other. Its possible that the second bsub talks to mbatchd before the first. strace shows that this is possible.

    [pid  8413] 18:48:30.533859 execve(".../bsub", ["bsub", "-I", "-J", "first", "ls /bin/*"], [/* 45 vars */] <unfinished ...>
    [pid  8414] 18:48:30.534415 execve(".../bsub", ["bsub", "-I", "-w", "done(first)", "-J", "second", "ls /usr/ &"], [/* 45 vars */] <unfinished ...>
    ...
    [pid  8414] 18:48:30.572521 connect(5, {sa_family=AF_INET, sin_port=htons(6881), sin_addr=inet_addr("a.b.c.d")}, 16 <unfinished ...>
    [pid  8413] 18:48:30.573422 connect(5, {sa_family=AF_INET, sin_port=htons(6881), sin_addr=inet_addr("a.b.c.d")}, 16 <unfinished ...>
    
Michael Closson
  • 902
  • 8
  • 13