I am running my program with slurm. I want all output (and all errors) to go to logfile.log. My sbatch script is
#!/bin/bash
#SBATCH --output=logfile.log
#SBATCH --error=logfile.log
srun PROGRAM
I assume that this will behave identically if I changed the run line to srun PROGRAM > logfile.log
and I am already catching all output and errors. Is that correct?
With a submission script such as
#!/bin/bash
#SBATCH --output=logfile.log
#SBATCH --error=logfile.log
srun PROGRAM > logfile.log
the logfile.log
will be created by Slurm at the beginning of the job, and then truncated at the start of the srun
command.
What you might loose in the process is any message written out during prologs if any. Other than that, it should be ok, but there may be some corner cases where it could fail and is therefore probably not a good practice.