Bash – How to check SLURM environmental variables programmatically

bashenvironment-variablesshell-scriptslurm

How can I programmatically access SLURM environmental variables, like MaxArraySize or MaxJobCount? I would like to partition my job arrays into chunks of the allowed maximum size. Can this information be queried with any of SLURM's commands? So far, I have failed to find relevant information on this over the net. Finding slurm.conf on each machine and extract the relevant line from it is not a very robust solution.

Best Answer

$ scontrol show config | grep -E 'MaxArraySize|MaxJobCount'
MaxArraySize            = 1001
MaxJobCount             = 1000000

Will that be enough for what you're wanting to do?

To get only the value for e.g. MaxArraySize:

$ scontrol show config | sed -n '/^MaxArraySize/s/.*= *//p'

As a shell function:

slurm_conf_value () {
    scontrol show config | sed -n "/^$1/s/.*= *//p"
}

MaxArraySize="$(slurm_conf_value 'MaxArraySize')"

These are not environment variables in the Unix sense, but configuration settings in Slurm. They are variables for configuring the "Slurm environment" though.

Related Question