Lesson 4: Submitting Batch Jobs¶
To submit a batch job, it is recommended to write a script which
describes the resources your job needs and how to run the job. We
suggest that you write your job scripts using a text editor installed on
the cluster (such as vim
) because Windows uses different characters to
represent newlines in files. This can cause issues when a script has
been written on a Windows machine and transferred to the cluster. For
more information about Windows newline characters, see
here.
Let's create a simple job script and submit it to the cluster for execution:
[USERNAME@login-01 ~]$ vim example.sh
Inside the 'example.sh' file, add the following lines, write and quit the file:
#!/bin/bash
#$ -cwd # Set the working directory for the job to the current directory
#$ -j y # Join standard out (stdout) and standard error (stderr) streams
#$ -pe smp 1 # Request 1 serial core
#$ -l h_rt=1:0:0 # Request a 1 hour runtime
#$ -l h_vmem=1G # Request 1GB of memory (RAM)
echo "my first UGE job!"
date
hostname
This can then be run with qsub
:
[USERNAME@login-01 ~]$ qsub example.sh
Your job 1234 ("example.sh") has been submitted
Let's display the job output:
[USERNAME@login-01 ~]$ cat example.sh.o1234
my first UGE job!
Thu Jul 26 15:03:17 BST 2024
ddy32
This demonstrates that the job was successfully ran on host 'ddy32' and
date
was executed at the datestamp above.