Create the R script
Using a text editor – examples include vim and nano – create an R script with the filename
example.r and the following contents:
# Define the suvs vector with 5 values
suvs <- c(4,4,6,6,16)
# Create a histogram for suvs
Creating the job script
Using a text editor create your shell script with the filename:
R_Example.sh and the following contents (the colours are only used for illistration purposes below):
# Merge standard output and standard error streams into the named file.
#PBS -j oe
# Set the name of the job
#PBS -N R_Example
# Advise the scheduler that the job requires one cpu (ppn) from one node.
#PBS -l nodes=1:ppn=1
# Advise the scheduler about the amount of physical memory required.
# kb for kilobytes, mb for megabytes, gb for gigabytes.
#PBS -l pmem=200mb
# Advise the scheduler that this job will have completed within 10 minutes.
#PBS -l walltime=00:10:00
# Send mail at batch job abort/exit to the Email address provided.
#PBS -m ae
#PBS -M firstname.lastname@example.org
module load R
R -f example.r
- The very first line of the script file is the Shebang, the shebang must always be the first line.
The second section contains the PBS directives. For more information on PBS directives please see the HPC PBSPro script files page.
- The third section outputs information about the job, and is only included as an example of what can be done.
- The fourth section contains the commands that are actually run in the job. In this case we are using a bash shell.
Submitting the Job - qsub
The final step is to submit the job to the job scheduler:
Monitoring the Job - qstat
Once the job has been submitted you can monitor its progress by using the qstat command.
When you first submit your job it is placed into the job queue, and its status column contains
Q, meaning the job is in the queue:
Once your job starts running its status changes to
You can display all of the jobs you are running:
All of the jobs running on the cluster:
Deleting a job - qdel
If you need to your job you can use the qdel command
Your job's Output
Different programs have different ways of outputting their data. If they output data directly to a file then your results will be in whatever file you specified (Rplots.pdf in this example). If, however, the results are printed out to the standard out then PBS captures the output into a file for you.