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).
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With