Yes, you can retrieve Slurm job environment variables in several ways, depending on your needs and the context of your job. Here’s how you can do it:
scontrol
You can use the scontrol command to inspect the environment variables of a running or completed Slurm job:
scontrol show job <job_id> --oneliner
This will output a long line containing all the job details, including the environment variables if they were set.
To specifically see the environment variables, you can use:
scontrol show job <job_id> | grep Environment
srun
--export
If you want to pass environment variables to a Slurm job, you can use the --export option with srun or sbatch:
sbatch
srun --export=ALL,MY_VAR=value your_command
This will export all current environment variables and also set MY_VAR for the job.
MY_VAR
To retrieve the environment variables from within the job, you can use:
printenv
or
env
inside your job script.
sacct
For completed jobs, you can use sacct to see job details, though it may not always show environment variables directly:
sacct -j <job_id> --format=JobID,JobName,Env
If you submit a job using sbatch, you can pass environment variables in the submission script:
#!/bin/bash #SBATCH --job-name=my_job #SBATCH --export=ALL,MY_VAR=value echo "MY_VAR is: $MY_VAR"
If you want to check the environment variables of a running job, you can use:
scontrol show job <job_id> | grep -i env
If you want to see the environment variables of a running job, you can use:
srun --jobid=<job_id> env
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.
Vibe can make mistakes. Check answers. Learn more