Writing Submit Scripts

After having tested the components of your script, you are now ready to assemble and submit it to the cluster. This page covers the overall scripting process provided by the example.pbs script that is automatically installed in your Home directory when your account is created. Please review example.pbs for additional scripting comments.

1. Enter the Text Editor:

To create a script, you must first enter the nano command to activate the editor: 

$ nano filename


2. Establish the Script Language:

The first line of the script declares the scripting language using a #! (hashbang). Most scripts on the cluster are written in bash and will therefore begin with:



3. Add Scheduler Resource Requests:

Name the job so it will be easy to identify in qstat and in your directory. Otherwise, the job will assume the name of the submit script:

#PBS -N example   # distinguishes the output of your script from the filename used to create it. 

Establish the walltime, memory, and processor speed required to run the job:

#PBS -l walltime=00:10:00  # request a runtime of 10 minutes for the script
#PBS -l nodes=1:ppn=4      # request 4 cores from 1 node
#PBS -l vmem=2000mb        # request 2000 megabytes of memory

Note: Hash marks before PBS commands do not indicate comments. They are required.


4. Configure the Environment:

Add modules to the script:

module load bowtie   # module designates the command
                     # load designates the subcommand
                     # bowtie designates the software package 

Show loaded modules. This will document loaded software and its version numbers in the job's output file:

module list 2>&1

Change some bash settings to make scripting easier:

set -o nounset     # treat referencing an unset variable as an error.
set -o errexit     # stop execution and exit this script on error.

Change the script's working directory to the directory from which the script was submitted:

[[ -n "${PBS_O_WORKDIR:-}" ]] && cd "$PBS_O_WORKDIR"


5. Provide the Input file name:


6. Add Program that Processes the Input File and Generates the Output File:

bowtie -p 4 -t -S --un e_coli-miss.fq /lustre/sw/bowtie/-.12.7/indexes/e_coli $INPUT e_coli-hits.sam 

7. Exit the Editor:

When you have completed your script, you must exit the editor:

CTRL-X  (^X)           # activates the exit process.
Y                      # prompts you to save the script; 
File Name to Write:    # prompts you to name or rename the file.                   
return:                # returns you back to the command Line.