Skip to content

Running multiple jobs sequentially

Create a python script (python_script.py)with the following code.

python_script.py

1
print("Hello, World!")

Create an R script (r_script.R)with the following code.

r_script.R  

1
2
3
4
5
z=rnorm(10000,mean=10,sd=2)
mean(z)
sd(z)
pdf(file="r_histogram.pdf")
hist(z,freq=FALSE,nclass=100)

Make a copy of hello.sb and name it multi_seq.sb

Edit multi_seq.sb to run the tasks, python_script.py and r_script.r :

  • Request resources
  • Load the required modules, 
  • sequentially run the two scripts

Submit job to compute node

Answer  

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#Make a copy of hello.sb and name it multi_seq.sb
cp hello.sb multi_seq.sb

#Using your favorite editor(nano, vi, emacs, gedit, etc.), 
#make the following edits to the multi_seq.sb script to run the tasks, python_script.py and r_script.r simultaneously:

gedit multi_seq.sb

#Request resources: Typically you'll need to request the largest number of nodes needed for each task. Since each task above only uses one node and one core there is no change to the number of nodes or cores.

#Load the required modules 
module load R/3.5.0-X11-20180131
module load python

#sequentially run the two scripts
python3 python_script.py
Rscript r_script.R

#Submit job to compute node: Execute the following at the command line
sbatch multi_seq.sb