From GridWiki
Revision as of 06:58, 13 August 2012 by LindaLopez (talk | contribs) (minor updates)
Jump to: navigation, search

Load Script

The following script just creates jobs. It is useful for testing your settings. No error checking and you have to modify the -q option to fit with your system.


# First argument is the number of jobs
# Second argument is the seconds to sleep

                -q "'*&!boinc'" \
                -cwd \
                -j y \
                -V \
                -N load \
                -o `pwd`/load.out \

for i in `seq $1`
  qsub $QSUB_OPTIONS /sjr/beodata/local/bin/vanilla_job.sh sleep $2

Using Ganglia as Load Sensor

See Using Ganglia As Load Sensor for guidance on using Ganglia as a load sensor for Grid Engine.

Modding qstat

The output from qstat -ext, while complete, is overly verbose (and over 200 characters wide) in many cases. In SGE 5.3, this will strip out bits about the Department, Deadline, PE Master, and Array Task columns; items frequently unused. It makes a good alias (such as "eqstat", or something):

 qstat -ext | cut -c 1-33,39-45,66-92,110-191

Modding qstat Redux

A longer script, but more condensed output from Andy Schwierskott, pulled from the SGE mailing list:

     echo "JobId     P    S  Project     User Tot-Tkt   ovrts   otckt   dtckt   ftckt   stckt  shr"
  echo "---------------------------------------------------------------------------------------"
  qstat -ext -s rs | grep -v job-ID | sed /-------------/d | \
     gawk '{ printf("%5s %4s %4s %8s %8s %7s %7s %7s %7s %7s %7s %4s\n", \
                   $1, $2, $7, $5, $4, $13, $14, $15, $16, $17, $18, $19) }'
  echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
  qstat -ext -s p | grep -v job-ID | sed /-------------/d | \
      gawk '{ printf("%5s %4s %4s %8s %8s %7s %7s %7s %7s %7s %7s %4s\n", \
                  $1, $2, $7, $5, $4, $10, $11, $12, $13, $14, $15, $16 ); }'

User Management

If you have lots of users and groups to add at once, and your userlists map to unix groups, qconf can help automate this a bit. This awk snippet looks for entries starting with "grp", and generates a qconf entry to create a matching userlist.

 awk -F: '/^grp/{print "qconf -au ",$4,$1}' /etc/group


If your user's have the same shared file space as the cluster this alias will change directory to the current working directory of the passed in job id.

It has to be an alias (or sourced) in order to affect the current shell.

I use the tcsh, and that is why there is all of the bizarre back slashing.

Add the line below to the system shell startup file or ~/.tcshrc

# tcsh:
alias qcd cd\ \`qstat\ -j\ \!\*\|awk\ \'/^cwd/\{print\ \$2\}\'\`

For bash/ksh/zsh, a shell function works well:

function qcd {
    cd `qstat -j $1 | awk '/^cwd/{print $2}'`;

Might could revisit this to make it a little nicer with the new XML format?


This script just sums up the processors that aren't performing a task. You will have to change the qstat options to suite your configuration.


qstat -g c -l arch=lx24-amd64 -q all.q | awk 'NR > 2 {sum = sum + $4} END {print sum}'


The following script will 'tail' the end of the standard output file of the passed in job id.


if [ $# -ne 1 ]; then
  echo "Usage:"
  echo "  $0 <sge_job_number>"

out_path=`qstat -j $1|grep ^stdout_path_list|awk '{print $2}'`

if [ "X$out_path" == "X" ]; then

if [ $out_path == "/dev/null" ]; then
  echo "Standard output is not available because directed to /dev/null"

tail -f $out_path

rj: qsub wrapper script

I created a wrapper script for qsub that allows my users to not need to know the complexity of the cluster configurations or job submission. I called the wrapper script 'rj' (for run jobs) in order to distinguish it from the collection of 'q*' apps that come with Grid Engine.

It has the following features:

  • Detects whether the application is checkpointable (with Condor)
  • Detects whether the application is MPI (currently known to work with OpenMPI and possibly MPICH), and then checks and makes sure gets the option to specify number of processors
  • Sets the maximum number of parallel processors to what is available so that the job can be dispatched immediately

Realize that this is very specific to my setup, and you will need to go through it and edit to match what you want it to do. It also has a lot of history that should probably be re-written. Approaching the idea to allowing 'rj' to accept all arguments that 'qsub' accepts and pass through, defaulting or forcing those options that I need to change.


# Default
                 -q "'*&!boinc'" \
                 -cwd \
                 -j y \
                 -M ${EMAIL} \
                 -V \

function usage(){
echo "
rj [-np NUM] [-i INPUT_FILE] [-mb] EXECUTABLE
    # EXECUTABLE runs on appropriate node.

     # Runs the MPI parallel MPI_EXECUTABLE on NUM nodes.
     # NUM can be a single number or a range, for example 2-8, would run the
     # MPI_EXECUTABLE on at least 2 processors up to 8 processors.

     # Runs EXECUTABLE with interactive input supplied by INPUT_FILE.

     # -b Waits for EXECUTABLE to finish (blocks) before returning.
     # -m Sends e-mail at end of job."
exit 1

# Detect the project option -P and the -i option
# Didn't try getopt - suspect wouldn't work since command can have options.
while [ $# -ne 0 ]
   case $1 in
        -P) EXTRA_OPTIONS=" $EXTRA_OPTIONS $1 $2 "
        -i) EXTRA_OPTIONS=" $EXTRA_OPTIONS $1 $2 "
        -np) MAXNP=$2
            max_num_slaves=`qstat -g c -l arch=lx24-amd64 | awk 'NR > 2 {sum = sum + $4} END {print int(sum - 1 - 0.1*sum)}'`
            if [ $MAXNP -gt $max_num_slaves ]; then
              echo "Number of slaves set to maximum allowable = ${max_num_slaves}."
         -b) EXTRA_OPTIONS=" $EXTRA_OPTIONS -sync y "
         -m) EXTRA_OPTIONS=" $EXTRA_OPTIONS -m eas "
         -h|--help) usage
         *) break

if [ $# -eq 0 ]; then

full_path=`which $1 2> /dev/null`
if [ "x"${full_path} == "x" ]; then
        echo "Executable $1 not found in any directory in $PATH"
  ... \n

The Power of Words and Emotional Bonding!

If you become steadfast in your abstentions of thoughts of harm directed toward others, all living creatures will cease to feel enmity in your presence. PatanjaliWords have power, incredible power, and this power lies in each and every one of us. Of course, its up to us to use this power for the greater good of all or not.

[The Power of Words and Emotional Bonding!]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

Guerilla Gardener Plants Joy in Potholes

Theyre the bane of cyclists and motorists alike, but one urban gardener has grown a fondness for potholes after deciding to spruce up cities around Europe by filling them up with miniature flower arrangements. Australian Steve Wheen, 34, who lives in London, has been using flowers and small-scale objects to transform urban potholes for the last three years. The self-styled guerrilla gardener has created mini gardens all around his home city but has now decided to bring joy to commuters across Europe with his unusual pothole creations.

[Guerilla Gardener Plants Joy in Potholes]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

The Limitations of Positive Thinking

Positive thinking is so firmly enshrined in our culture that knocking it is a little like attacking motherhood or apple pie. Many persons swear by positive thinking and quite a few have been helped by it. Nevertheless, it is not a very effective tool and can be downright harmful in some cases. There are much better ways to get the benefits that positive thinking allegedly provides.

[The Limitations of Positive Thinking]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

10 Keys to Happier Living

Action for Happiness has developed the 10 Keys to Happier Living based on a review of the latest scientific research relating to happiness. Everyones path to happiness is different, but the research suggests these Ten Keys consistently tend to have a positive impact on peoples overall happiness and well-being.

[10 Keys to Happier Living]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

New Toilet System Transform Waste into Electricity

Scientists from Nanyang Technological University (NTU) have invented a new toilet system that will turn human waste into electricity and fertilisers and also reduce the amount of water needed for flushing by up to 90 per cent compared to current toilet systems in Singapore.

[New Toilet System Transform Waste into Electricity]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]