Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slurm job, knowing what node it is on

Tags:

bash

slurm

Is there a way in bash/slurm for the script to know which node it is running on?

so I sbatch a bash script called wrapCode.sh, and I am monitoring script time as well as which node it is running on. I know how to monitor the script time, but is there a way to echo out at the end which node I was on?

sstat does this, but I need to know what my job id is, which the script also doesn't seem to know (or at least I haven't been able to find it).

like image 804
bnp0005 Avatar asked Dec 19 '22 07:12

bnp0005


2 Answers

The jobid for your job can be found in the environment variable SLURM_JOBID. This variable is automatically set by SLURM upon submission of your job.

As for finding the name of the node running your job, this can be found in the environment variable SLURMD_NODENAME.

The variable SLURM_NODELIST will give you a list of nodes allocated to a job (unless you run a job across multiple nodes, this will only contain one name).

There are lot of variables that contain information on your job, see https://slurm.schedmd.com/sbatch.html#lbAH

like image 140
Thomas Espe Avatar answered Jan 09 '23 01:01

Thomas Espe


A simple, yet effective, and often used, way to write in the job output on which node it ran is to add

srun hostname

to it. Also the job id is available from within the job script through environment variable SLURM_JOB_ID ; so you can use

sstat -j $SLURM_JOB_ID

in your slurm script to get the information you want.

like image 33
damienfrancois Avatar answered Jan 09 '23 01:01

damienfrancois