Sample Header Ad - 728x90

SLURM error and output files with custom variable name

0 votes
1 answer
160 views
I'd like my log files to be named after a variable. Since this isn't possible: #SBATCH --output some_software.${var}.out #SBATCH --error some_software.${var}.err I came across this work around but not sure if it's ok, or if it's wrong or if there's a better way: #!/bin/bash #SBATCH --job-name my_job #SBATCH --partition some_partition #SBATCH --nodes 1 #SBATCH --cpus-per-task 8 #SBATCH --mem 50G #SBATCH --time 6:00:00 #SBATCH --get-user-env=L #SBATCH --export=NONE var=$1 # SLURM doesn't support variables in #SBATCH --output, so handle logs manually if [ -z "$SLURM_JOB_ID" ]; then log_dir="/data/logs" sbatch --output="${log_dir}/some_software.${var}.out" \ --error="${log_dir}/some_software.${var}.err" \ "$0" "$var" exit fi /data/software/nextflow run /data/software/some_software/main.nf
Asked by Caterina (103 rep)
May 12, 2025, 10:46 PM
Last activity: May 13, 2025, 04:09 PM