Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| habrok:advanced_job_management:job_arrays [2024/03/14 14:32] – [Output and job information for job arrays] pedro | habrok:advanced_job_management:job_arrays [2026/03/27 14:09] (current) – pedro | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| In order to create a job array, start by creating the job script that you would need to run just one instance of the job. For instance, consider the following job script for running R: | In order to create a job array, start by creating the job script that you would need to run just one instance of the job. For instance, consider the following job script for running R: | ||
| - | < | + | < |
| #!/bin/bash | #!/bin/bash | ||
| #SBATCH --job-name=R_job | #SBATCH --job-name=R_job | ||
| Line 17: | Line 17: | ||
| Now suppose you want this to be run 100 times. You can simply add the array definition by adding the following line somewhere at the top of the script: | Now suppose you want this to be run 100 times. You can simply add the array definition by adding the following line somewhere at the top of the script: | ||
| - | < | + | < |
| #SBATCH --array=1-100 | #SBATCH --array=1-100 | ||
| </ | </ | ||
| Line 27: | Line 27: | ||
| So let us take it a step further: suppose we have 100 different R scripts that have to be run, which are named myscript1.r, | So let us take it a step further: suppose we have 100 different R scripts that have to be run, which are named myscript1.r, | ||
| - | < | + | < |
| #!/bin/bash | #!/bin/bash | ||
| #SBATCH --job-name=R_job | #SBATCH --job-name=R_job | ||
| Line 78: | Line 78: | ||
| A job array will get just one main job id, just like a regular job. However, the index values of the range will be used as suffix for the job id: < | A job array will get just one main job id, just like a regular job. However, the index values of the range will be used as suffix for the job id: < | ||
| - | The same kind of job ids will also be used in the output of SLURM tools like squeue and sacct. The squeue command will usually try to combine the jobs in the array into a single line, e.g.: | + | The same kind of job ids will also be used in the output of SLURM tools like '' |
| < | < | ||
| Line 85: | Line 85: | ||
| </ | </ | ||
| \\ | \\ | ||
| - | If you want to get each job of the array to appear on a separate line, you can pass the '' | + | If you want to get each job of the array to appear on a separate line, you can pass the '' |
| ===== Cancelling job arrays ===== | ===== Cancelling job arrays ===== | ||