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?