Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • much appreciated! Commented Jul 16, 2022 at 4:33
  • hmmm apologies I gave the accepted answer before testing it. Put this in the bash script !/bin/bash -l out_file=$(basename "$0") #SBATCH --gpus=1 #SBATCH -p long #SBATCH -o "err_${out_file%.*}.out" and it didn't output to that file for some reason. Echo printed out the correct string, but it's not outputting to that file. Any ideas? Commented Jul 16, 2022 at 5:49
  • You need to tell basename the suffix. But, having a .sh suffix to a file name is an anti-pattern. Commented Jul 16, 2022 at 16:34
  • @Gooby I don't understand how you intend the #SBATCH lines in your script to work. They don't match up to how a shell script functions except as a way to comment out (disable) lines, and that appears to be why it doesn't work when you try to use them. Can you explain what you're trying to do with them? Are you hoping to use multiple lines of the script to create the full sbatch command? Commented Jul 16, 2022 at 16:36
  • sorry I'm not super familiar with slurm and Linux this is just how I've seen others in my lab sbatch a slurm job. I don't even know what #SBATCH does exactly. Commented Jul 17, 2022 at 17:17