Home > Mobile >  Running multiples files jobs with one sbatch
Running multiples files jobs with one sbatch

Time:04-15

I want to run N files (N jobs) that are inside N folders that are in my pwd such :

Folder_1
   contains file_1
Folder_2
   contains file_2
|
|
|
Folder_N
   contains file_N

For one file_1 i just have to do : sbatch script.sh ./folder1/file_1.

But is there a way to make a loop for running the N files like :

for i in range(N):
sbatch script.sh ./folder_i/file_i

CodePudding user response:

Create a bash file as such :

#!/bin/bash
for i in {305..595..5} (or any range you want)
  do 
     sbatch script.sh ./folder_$i/file_$i
 done

make it executable via this link https://www.andrewcbancroft.com/blog/musings/make-bash-script-executable/ and it runs.

CodePudding user response:

I found a solution i just want to share it here,

#!/bin/bash
ls ./folder*/file* > file (stock paths in a file)
  while read p; do (read it line by line)
   sbatch script.sh "$p"
  done < file
  • Related