ODU Research Computing Forum

SLURM output files

I want an output file each time I run a job.

I know I could type: #SBATCH --output=Outputfile.txt on my script.

If I want to identify my output file by job I know I can add %J

Currently I am doing this:

#SBATCH --output=/PATH_TO_SOME_DIR/Outputfile_%J.txt

If I intend to run the same job a few times, is there a way to append each run and have the job identified to the same output file? Thanks!

The %J substring in the sbatch’s output specification is meant to be substituted with the Slurm job number. That is meant to produce DIFFERENT output file every time the job run. Which is sometimes what we want because we want to run many times and we want to preserve distinct outputs from every run.

If you want to append to the same file, then use this:

#SBATCH --output=/PATH_TO_SOME_DIR/Outputfile.txt
#SBATCH --open-mode=append

There is no more %J in the output file name. The --open-mode argument is either append, or truncate (meaning, the current content of the file will be erased). The second line is actually the default for Wahab right now, but added explicitly to be on the safe side.