HowTos / MoabScript

<< Moab | MoabIndexPage | MoabMatlab >>

Moab Script Example

This job shows a basic example of running a simple job in MOAB and some of the useful variables available to users from PBS (PBS is the resource manager, and MOAB is the scheduler). Below is an example MOAB script. In this example, this script is saved as moab.test.

#!/bin/bash

#MOAB -N moab_test

echo ------------------------------------------------------
echo -n 'Job is running on node '; cat $PBS_NODEFILE
echo ------------------------------------------------------
echo MOAB: qsub is running on $PBS_O_HOST
echo MOAB: originating queue is $PBS_O_QUEUE
echo MOAB: executing queue is $PBS_QUEUE
echo MOAB: working directory is $PBS_O_WORKDIR
echo MOAB: execution mode is $PBS_ENVIRONMENT
echo MOAB: job identifier is $PBS_JOBID
echo MOAB: job name is $PBS_JOBNAME
echo MOAB: node file is $PBS_NODEFILE
echo MOAB: current home directory is $PBS_O_HOME
echo MOAB: PATH = $PBS_O_PATH
echo ----------------------------------------------
echo ------------------------------------------------------
echo -n 'Job is running on node '; cat $PBS_NODEFILE
echo ------------------------------------------------------
echo ' '
echo ' '

The directive #MOAB -N moab_test names the job for moab and will consequently name the standard output and standard error to the files moab_test.o# and moab_test.e#, where # is the job number moab returns when the job is submitted. If the name is not specified, the default is for the batch system to create the two files and name them STDIN.o# and STDIN.e#, again #s refer to the job number returned at submission. To join the standard output and the standard error to a single file, add the directive:#MOAB -j oe. The remaining variables are self-explanatory. Below is the output from running this script (saved in a file as moab.test) in a users home directory, with a demonstration of a couple of the commands from the previous page:

maria@herbie:~/moab$ msub moab.test

58
#### Let's see what the queue looks like:
maria@herbie:~/moab$ showq

active jobs------------------------
JOBID              USERNAME      STATE PROCS   REMAINING            STARTTIME


0 active jobs             0 of 107 processors in use by local jobs (0.00%)
                           0 of 10 nodes active      (0.00%)

eligible jobs----------------------
JOBID              USERNAME      STATE PROCS     WCLIMIT            QUEUETIME


0 eligible jobs   

blocked jobs-----------------------
JOBID              USERNAME      STATE PROCS     WCLIMIT            QUEUETIME


0 blocked jobs   

Total jobs:  0
#### Looks like our job completed. Let's check. 
maria@herbie:~/moab$ checkjob 58
job 58

AName: moab_test
State: Completed 
Completion Code: 0  Time: Sun Apr 10 15:05:51
Creds:  user:maria  group:users  class:batch
WallTime:   00:00:01 of 1:00:00
SubmitTime: Sun Apr 10 15:05:50
  (Time Queued  Total: 00:00:00  Eligible: 00:00:00)

Total Requested Tasks: 1

Req[0]  TaskCount: 1  Partition: bettye  

Allocated Nodes:
[bettye:1]



IWD:            $HOME/moab
Executable:     /opt/moab/spool/moab.job.c9POvt

Execution Partition:  bettye
StartPriority:  0
PE:             1.00

#### Yup, all finished. Let's look at the output file we specified:
maria@herbie:~/moab$ cat moab_test.o58 
------------------------------------------------------
Job is running on node bettye
------------------------------------------------------
MOAB: qsub is running on bettye.shadlen.org
MOAB: originating queue is batch
MOAB: executing queue is batch
MOAB: working directory is /home/maria/moab
MOAB: execution mode is PBS_BATCH
MOAB: job identifier is 58.bettye.shadlen.org
MOAB: job name is moab_test
MOAB: node file is /var/spool/torque/aux//58.bettye.shadlen.org
MOAB: current home directory is /home/maria
MOAB: PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
----------------------------------------------
------------------------------------------------------
Job is running on node bettye
------------------------------------------------------

Moab parameters

There are several moab parameters that you can use in the preamble of your script or as a parameter to msub. If you give them in your script, you have to start the line with "#MOAB", for example "#MOAB -N name". A few useful options are:

Option 1Meaning
-N nameDeclares the name of your job to "name" (and outputfiles).
-l nodes=nRequests n nodes for this job
-j oeHave the standard output and the standard error write in the same logfile
-m abeHave moab mail a notification to you if the job gets aborted, begins or ends. You can use any combination of these letter, for example "-m e" if you are only interested if a jobs finishes.
-l walltime=hh:mm:ssTell the scheduler that your job will run for hh hours, mm minutes and ss seconds. Try to keep it accurate, without underestimating.
-q queueSpecify the queue to run in.
-l qos=QOSSpecify the quality of service QOS for this job.

Basic outline of a Moab Submit File:

#!/bin/bashchoose your shell (optional: default is your normal interpreter)
#MOAB –N f1Define Job Name
#MOAB -j oePut error and output in one file
#MOAB -l walltime=120:00Max time your script will take
cd $PBS_O_WORKDIRChange to working directory
./mytestRun Script

<< Moab | MoabIndexPage | MoabMatlab >>