运行多个文件作业用一个sbatch

发布于 2025-01-19 11:36:05 字数 331 浏览 7 评论 0原文

我想运行n个文件(n个作业),这些文件(n个作业)在我的pwd中的n个文件夹中:

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

对于一个file_1,我只需要做:sbatch script.sh ./folder1/file_1即可。

但是,有没有办法使运行n个文件的循环如下:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老街孤人 2025-01-26 11:36:05

创建一个bash文件:

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

使其通过此链接 https: //www.andrewcbancroft.com/blog/musings/make-bash-script-executable/
它运行。

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.

明明#如月 2025-01-26 11:36:05

我找到了一个解决方案,我只想在这里分享

#!/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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文