2

I have some jobs started with sbatch, e.g.

a=$(sbatch ...)
b=$(sbatch ...)

Now a third job is queued after a or b are done:

c=$(sbatch --dependency=afterany:$a:$b ...)

How can I pass the exit status of task a and b to the script of c?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Philipp H.
  • 1,513
  • 3
  • 17
  • 31

1 Answers1

1

You have several options;

  • have c read a file on disk, that is produced by a and b;
  • have c use sacct to retrieve the status of a and b:

    sacct -X -n -o state -j $a

damienfrancois
  • 52,978
  • 9
  • 96
  • 110
  • Using `sacct -o -n -o state -j ` I get the error `sacct: error: Invalid field requested: "-n"`. If I use `sacct -o state -j ` I get meaningful output, but for some jobs I get duplicated output, e.g. `State\n----------\n RUNNING\n RUNNING`. Do you know why? Thanks. – Josh Mar 29 '20 at 23:29
  • 1
    because `sacct` will output one line for the job and as many subsequent lines as there are job steps. Us `-X` to have only one line. – damienfrancois Mar 30 '20 at 15:43