[slurm-users] How to access environment variables in submit script?
Thomas M. Payerle
payerle at umd.edu
Thu May 10 09:00:37 MDT 2018
I don't believe that is possible.
The #SBATCH lines are comments to the shell, so it does not do any variable
expansion there.
To my knowledge, Slurm does not do any variable expansion in the parameters
either.
If you really needed that sort of functionality, you would probably need to
have something else
pre-process the input submission script to produce the real submission
script which is then passed
to sbatch. E.g. something along the lines of
cat - <<EOF > preprocess-sbatch
#!/bin/bash
SCRIPT="$1"
shift
sed -e "s/\$SCRATCH/$SCRATCH/g" < $SCRIPT | cat "$@"
EOF
On Thu, May 10, 2018 at 9:19 AM, Dmitri Chebotarov <dchebota at gmu.edu> wrote:
> Hello
>
> Is it possible to access environment variables in a submit script?
> F.e. $SCRATCH is set to a path and I like to use $SCRATCH variable in
> #SBATCH:
>
> #SBATCH --output=$SCRATCH/slurm/%j.out
> #SBATCH --error=$SCRATCH/slurm/%j.err
>
> Since it's Bash script, # are ignored and I suspect these variables need
> to be defined on Slurm controller (?).
>
> As a workaround I can run 'sbatch --output=$SCRATCH/slurm/%j.out
> --error=$SCRATCH/slurm/%j.err <myscript>' and it works. But is there any
> way to use non-slurm env variables via #SBATCH?
>
> Thank you
>
>
--
Tom Payerle
DIT-ACIGS/Mid-Atlantic Crossroads payerle at umd.edu
5825 University Research Park (301) 405-6135
University of Maryland
College Park, MD 20740-3831
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schedmd.com/pipermail/slurm-users/attachments/20180510/3018b8a9/attachment-0001.html>
More information about the slurm-users
mailing list