# Page History

## Key

• This line was added.
• This line was removed.
• Formatting was changed.

There are a number of different types of jobs you can run on Viking depending on your workloads.  Below we provide a number of examples depending on the type of job you are running.  You can download  this  folder which contains all of the job script examples below or copy the same folder whilst on viking with the following command.

Code Block
language bash
`[abc123@login1(viking) ~]$cp -r /mnt/lustre/groups/viking-examples/hpc_course/jobscripts .` ... Code Block language bash ```# Submit a job array with index values between 0 and 31 [usr1@login1abc123@login1(viking) scratch]$ sbatch --array=0-31 basic.job```

...

Code Block
language bash
```# Submit a job array with index values of 1, 3, 5 and 7
[usr1@login1abc123@login1(viking) scratch]$sbatch --array=1,3,5,7 basic.job``` ... Code Block language bash ```# Submit a job array with index values between 1 and 7 # with a step size of 2 (i.e. 1, 3, 5 and 7) [usr1@login1abc123@login1(viking) scratch]$ sbatch --array=1-7:2 basic.job```

...

Code Block
language bash
```# Cancel array ID 1 to 3 from job array 20
[usr1@login1abc123@login1(viking) scratch]$scancel 20_[1-3] # Cancel array ID 4 and 5 from job array 20 [usr1@login1acb123@login1(viking) scratch]$ scancel 20_4 20_5

# Cancel all elements from job array 20
[usr1@login1abc123@login1(viking) scratch]$scancel 20``` ... When a job array is submitted to Slurm, only one job record is created. Additional job records will only be created when the state of a task in the job array changes, typically when a task is allocated resources, or its state is modified using the scontrol command. By default, the squeue command will report all of the tasks associated with a single job record on one line and use a regular expression to indicate the "array_task_id" values as shown below. Code Block language bash ```[usr1@login1abc123@login1(viking) scratch]$ squeue -u usr1
JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
9_[102-500]     nodes array_jo     usr1 PD       0:00      1 (None)
9_1     nodes array_jo     usr1  R       0:01      1 node169
9_2     nodes array_jo     usr1  R       0:01      1 node169
9_3     nodes array_jo     usr1  R       0:01      1 node169
9_4     nodes array_jo     usr1  R       0:01      1 node169
9_5     nodes array_jo     usr1  R       0:01      1 node169
9_6     nodes array_jo     usr1  R       0:01      1 node169
9_7     nodes array_jo     usr1  R       0:01      1 node169
9_8     nodes array_jo     usr1  R       0:01      1 node169
9_9     nodes array_jo     usr1  R       0:01      1 node170
9_10     nodes array_jo     usr1  R       0:01      1 node170
...```

...

Section
border true

Column
width 50%

Code Block
language bash
```[usr1@login1abc123@login1(viking) scratch]$ls idata/ Wed Nov 19 14:22:26 GMT 2014 Wed Nov 19 14:25:14 GMT 2014 Wed Nov 19 14:22:32 GMT 2014 Wed Nov 19 14:25:21 GMT 2014 Wed Nov 19 14:22:37 GMT 2014 Wed Nov 19 14:25:28 GMT 2014 Wed Nov 19 14:22:45 GMT 2014 Wed Nov 19 14:25:36 GMT 2014 Wed Nov 19 14:22:52 GMT 2014 Wed Nov 19 14:25:43 GMT 2014 Wed Nov 19 14:23:00 GMT 2014 Wed Nov 19 14:25:51 GMT 2014 Wed Nov 19 14:23:07 GMT 2014 Wed Nov 19 14:25:58 GMT 2014 Wed Nov 19 14:23:15 GMT 2014 Wed Nov 19 14:26:06 GMT 2014 Wed Nov 19 14:23:22 GMT 2014 Wed Nov 19 14:26:13 GMT 2014 Wed Nov 19 14:23:29 GMT 2014 Wed Nov 19 14:26:20 GMT 2014 Wed Nov 19 14:23:37 GMT 2014 Wed Nov 19 14:26:28 GMT 2014 Wed Nov 19 14:23:44 GMT 2014 Wed Nov 19 14:26:35 GMT 2014 Wed Nov 19 14:23:52 GMT 2014 Wed Nov 19 14:26:43 GMT 2014 Wed Nov 19 14:23:59 GMT 2014 Wed Nov 19 14:26:50 GMT 2014 Wed Nov 19 14:24:07 GMT 2014 Wed Nov 19 14:26:57 GMT 2014 Wed Nov 19 14:24:14 GMT 2014 Wed Nov 19 14:27:05 GMT 2014 Wed Nov 19 14:24:21 GMT 2014 Wed Nov 19 14:27:12 GMT 2014 Wed Nov 19 14:24:29 GMT 2014 Wed Nov 19 14:27:20 GMT 2014 Wed Nov 19 14:24:36 GMT 2014 Wed Nov 19 14:27:27 GMT 2014 Wed Nov 19 14:24:44 GMT 2014 Wed Nov 19 14:27:35 GMT 2014 Wed Nov 19 14:24:51 GMT 2014 Wed Nov 19 14:27:42 GMT 2014 Wed Nov 19 14:24:59 GMT 2014 Wed Nov 19 14:27:50 GMT 2014 Wed Nov 19 14:25:06 GMT 2014 Wed Nov 19 14:27:57 GMT 2014 [usr1@login1abc123@login1(viking) scratch]$ ls -1 idata/ > data.files
[usr1@login1abc123@login1(viking) scratch]$cat data.files Wed Nov 19 14:22:26 GMT 2014 Wed Nov 19 14:22:32 GMT 2014 Wed Nov 19 14:22:37 GMT 2014 Wed Nov 19 14:22:45 GMT 2014 Wed Nov 19 14:22:52 GMT 2014 Wed Nov 19 14:23:00 GMT 2014 Wed Nov 19 14:23:07 GMT 2014 Wed Nov 19 14:23:15 GMT 2014 Wed Nov 19 14:23:22 GMT 2014 Wed Nov 19 14:23:29 GMT 2014 Wed Nov 19 14:23:37 GMT 2014 Wed Nov 19 14:23:44 GMT 2014 Wed Nov 19 14:23:52 GMT 2014 Wed Nov 19 14:23:59 GMT 2014 Wed Nov 19 14:24:07 GMT 2014 Wed Nov 19 14:24:14 GMT 2014 Wed Nov 19 14:24:21 GMT 2014 Wed Nov 19 14:24:29 GMT 2014 Wed Nov 19 14:24:36 GMT 2014 Wed Nov 19 14:24:44 GMT 2014 Wed Nov 19 14:24:51 GMT 2014 Wed Nov 19 14:24:59 GMT 2014 Wed Nov 19 14:25:06 GMT 2014 Wed Nov 19 14:25:14 GMT 2014 Wed Nov 19 14:25:21 GMT 2014 Wed Nov 19 14:25:28 GMT 2014 Wed Nov 19 14:25:36 GMT 2014 Wed Nov 19 14:25:43 GMT 2014 Wed Nov 19 14:25:51 GMT 2014 Wed Nov 19 14:25:58 GMT 2014 Wed Nov 19 14:26:06 GMT 2014 Wed Nov 19 14:26:13 GMT 2014 Wed Nov 19 14:26:20 GMT 2014 Wed Nov 19 14:26:28 GMT 2014 Wed Nov 19 14:26:35 GMT 2014 Wed Nov 19 14:26:43 GMT 2014 Wed Nov 19 14:26:50 GMT 2014 Wed Nov 19 14:26:57 GMT 2014 Wed Nov 19 14:27:05 GMT 2014 Wed Nov 19 14:27:12 GMT 2014 Wed Nov 19 14:27:20 GMT 2014 Wed Nov 19 14:27:27 GMT 2014 Wed Nov 19 14:27:35 GMT 2014 Wed Nov 19 14:27:42 GMT 2014 Wed Nov 19 14:27:50 GMT 2014 Wed Nov 19 14:27:57 GMT 2014``` Column width 50% Code Block language bash true ```#!/bin/bash #SBATCH --job-name=basic_job_test # Job name #SBATCH --mail-type=END,FAIL # Mail events (NONE, BEGIN, END, FAIL, ALL) #SBATCH --mail-user=abc123@york.ac.uk # Where to send mail #SBATCH --ntasks=1 # Run on a single CPU #SBATCH --mem=1gb # Job memory request #SBATCH --time=00:05:00 # Time limit hrs:min:sec #SBATCH --output=array_job_%A_%a.log # Standard output and error log #SBATCH --account=PROJECTCODE # Project account #SBATCH --array=1-46 # Array range filename=$(awk NR==$SLURM_ARRAY_TASK_ID data.files) Rscript analyseData.R "idata/$filename" "results/\$filename.rst"```

...