Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use slurm job id

When I launch a computation on the cluster, I usually have a separate program doing the post-processing at the end :

sbatch simulation sbatch --dependency=afterok:JOBIDHERE postprocessing 

I want to avoid mistyping and automatically have the good job id inserted. Any idea? Thanks

like image 926
user1824346 Avatar asked Nov 13 '13 17:11

user1824346


People also ask

How do I submit a Slurm job?

There are two ways of submitting a job to SLURM: Submit via a SLURM job script - create a bash script that includes directives to the SLURM scheduler. Submit via command-line options - provide directives to SLURM via command-line arguments.

How do I submit an array job Slurm?

The syntax for submitting job arrays is: sbatch --array <indexlist>[%<limit>] arrayscript.sh . The <limit> is optional. Submitting the script to SLURM will return the parent SLURM_ARRAY_JOB_ID.

What is job step in Slurm?

A job consists in one or more steps, each consisting in one or more tasks each using one or more CPU. Jobs are typically created with the sbatch command, steps are created with the srun command, tasks are requested, at the job level with --ntasks or --ntasks-per-node , or at the step level with --ntasks .


1 Answers

You can do something like this:

RES=$(sbatch simulation) && sbatch --dependency=afterok:${RES##* } postprocessing 

The RES variable will hold the result of the sbatch command, something like Submitted batch job 102045. The construct ${RES##* } isolates the last word (see more info here), in the current case the job id. The && part ensures you do not try to submit the second job in the case the first submission fails.

like image 103
damienfrancois Avatar answered Sep 22 '22 23:09

damienfrancois