diff --git a/docs.it4i/cs/job-scheduling.md b/docs.it4i/cs/job-scheduling.md index 0eb40966fde36c843d69edb98b1db7ceb0347465..6da3a07d4fc98a7b7e2f6112f9b87351e274dc79 100644 --- a/docs.it4i/cs/job-scheduling.md +++ b/docs.it4i/cs/job-scheduling.md @@ -25,12 +25,55 @@ $ squeue --me 104 p01-arm interact user R 1:48 2 p01-arm[01-02] ``` -Show job details +Show job details for specific job ```console -$ scontrol show job 104 +$ scontrol -d show job JOBID ``` +Show job details for executing job from job session + +```console +$ scontrol -d show job $SLURM_JOBID +``` + +## Slurm job environment variables + +Slurm provides usefull information to the job via environment variables. Environment variables are available on all nodes allocated to job when accessed via Slurm supported means (srun, compatible mpirun). + +See all Slurm variables +``` +set |grep ^SLURM +``` + +Useful Slurm variables +| variable name | description | example | +| ------ | ------ | ------ | +|SLURM_JOBID| job id of the executing job| 593 | +|SLURM_JOB_NODELIST| nodes allocated to job | p03-amd[01-02] | +|SLURM_JOB_NUM_NODES| number of nodes allocated to job | 2 | +|SLURM_STEP_NODELIST| nodes allocated to job step | p03-amd01 | +|SLURM_STEP_NUM_NODES| number of nodes allocated to job | 1 | +|SLURM_JOB_PARTITION| name of the partition | p03-amd | +|SLURM_SUBMIT_DIR| submit directory | /scratch/project/open-xx-yy/work | + +See [Slurm srun documentation][2] for details. + +Get job nodelist +``` +$ echo $SLURM_JOB_NODELIST +p03-amd[01-02] +``` + +Expand nodelist to list of nodes. +``` +$ scontrol show hostnames $SLURM_JOB_NODELIST +p03-amd01 +p03-amd02 +``` + +## Running interactive jobs + Run interactive job ```console @@ -46,6 +89,8 @@ Run interactive job, with X11 forwarding !!! warning Do not use `srun` for initiating interactive jobs, subsequent `srun`, `mpirun` invocations would block forever. +## Running batch jobs + Run batch job ```console @@ -278,3 +323,4 @@ $ scontrol -d show job $SLURM_JOBID | grep -i gres ``` [1]: https://slurm.schedmd.com/ +[2]: https://slurm.schedmd.com/srun.html#SECTION_OUTPUT-ENVIRONMENT-VARIABLES