Slurm job, knowing what node it is on
bash, slurm
Solution
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.
Problem
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).