I've written a sbatch script for array launching and I'd like to automatically add the number of jobs (without specifying it manually within the script).
I was thinking maybe as a variable, something like that:
sbatch myscript.sbs --n_jobs=30
(or sbatch --n_jobs=30 myscript.sbs
)
... and this would be the ideal script (which, of course, it's not working):
#!/bin/bash
#SBATCH --job-name=test
#SBATCH --output=test.log
#SBATCH --mem=2G
#SBATCH --partition=short
#SBATCH --cpus-per-task=10
#SBATCH --array=1-${n_jobs}%5 # <<<--- adjust according number of files to process
<misc commands>