1. Simple 'hostname' job

Setting up some folders to perform experiments

We'll setup a root directory, called 'examples', where we'll store all the input files, scripts and results we're going to test.

ijimenez@login:~/examples$ mkdir hostname
ijimenez@login:~/examples$ cd hostname
ijimenez@login:~/examples/hostname$

The easiest example: where do you run?

To illustrate that we have no prior knowledge of which node is goin to execute our tasks, we'll program a little script to send us the hostname who will be running our scripts. And within the file we do a simple echo of the environment variable $HOSTNAME. The hostname.sh file comes with only two lines:

ijimenez@login:~/examples/hostname$ vi hostname.sh
#!/bin/bash
echo "Hello, this is your script, running on $HOSTNAME"

And now we'll setup the job file for hostname.sh. Comments are explained on the file:

ijimenez@login:~/examples/hostname$ vi hostname.sub
#!/bin/bash ##########################################
# Options and parameters for SGE:
##########################################
# (1) Name of the job to identify (flag -N)
# The parameter passed to -N is an alias to the script
# -----------------------------------------
#$ -N The-easiest-job
#
# (2) We'll redirect the output files to
# our working directory (flags -cwd, -e, -o)
# ---------------------------------------
#$ -cwd
#$ -o __hostname.out
#$ -e __hostname.err
#
# (3)Finally, we call the script
# ------------------------------
sh hostname.sh

And now we simply run the job, telling the scheduler to register the .sub file:

ijimenez@login:~/examples/hostname$ qsub hostname.sub
Your job 153605 ("The-easiest-job") has been submitted
ijimenez@login:~/examples/hostname$ 

Finally, we check the contents of the output file:

    ijimenez@login:~/examples/hostname$ more __hostname.out 
    Hello, this is your script, running on node09