Search code examples
slurmhpc

When exactly does SLURM export environmental variables?


With the option --export=ALL, the current environmental variables should be visible to the job script when submitted as

sbatch --export=ALL jobscript.sh

My question is, when exactly does SLURM do the export? Does the export happen when the job is submitted or when it actually starts running? If the job spends some time in the queue and the environmental variables are changed after the job submission but before running starts, which version of them will be "seen" by the job?


Solution

  • The job will see the environment as it is at the time the sbatch command is run.

    When sbatch is run, Slurm will save the environment in a file named hash.<last digit of the job>/job.<jobid>/environmnet in the directory configured as StateSaveLocation.