Difference between revisions of "Batch Jobs"

From bwHPC Wiki
Jump to: navigation, search
m (E-Mail notification of mjobctl -c)
m (E-Mail notification of mjobctl -c)
Line 1,253: Line 1,253:
<source lang=email>
<source lang=email>
From: slurm@uc1-sv1.scc.kit.edu
From: slurm@uc1-sv1.scc.kit.edu
Subject: SLURM Job_id=8374356 Name=fasta36_job Ended, Run time 00:01:30, CANCELLED, ExitCode 0
Subject: SLURM Job_id= 8374426 Name=fasta36_job Ended, Run time 00:01:30, CANCELLED, ExitCode 0
from the resource manager shortly after the job was removed from the queue.
from the resource manager shortly after the job was removed from the queue.

Revision as of 18:00, 15 January 2016


1 Moab® HPC Workload Manager

1.1 Specification

The Moab Cluster Suite is a cluster workload management package, available from Adaptive Computing, Inc., that integrates the scheduling, managing, monitoring and reporting of cluster workloads. Moab Cluster Suite simplifies and unifies management across one or multiple hardware, operating system, storage, network, license and resource manager environments.

Any kind of calculation on the compute nodes of a bwHPC cluster of tier 2 or 3 requires the user to define calculations as a sequence of commands or single command together with required run time, number of CPU cores and main memory and submit all, i.e., the batch job, to a resource and workload managing software. All bwHPC cluster of tier 2 and 3, including have installed the workload managing software MOAB. Therefore any job submission by the user is to be executed by commands of the MOAB software. MOAB queues and runs user jobs based on fair sharing policies.

1.2 Moab Commands (excerpt)

Some of the most used Moab commands for non-administrators working on a HPC-C5 cluster.

MOAB commands Brief explanation
msub Submits a job and queues it in an input queue [msub]
checkjob Displays detailed job state information [checkjob]
showq Displays information about active, eligible, blocked, and/or recently completed jobs [showq]
showbf Shows what resources are available for immediate use [showbf]
showstart Returns start time of submitted job or requested resources [showstart]
canceljob Cancels a job (opsoleted!) [canceljob]
mjobctl Cancel a job and more job control options [mjobctl]

1.3 Job Submission : msub

Batch jobs are submitted by using the command msub. The main purpose of the msub command is to specify the resources that are needed to run the job. msub will then queue the batch job. However, starting of batch job depends on availability of the requested resources and the fair sharing value.

1.3.1 msub Command Parameters

The syntax and use of msub can be displayed via:

$ man msub

msub options can be used from the command line or in your job script.

msub Options
Command line Script Purpose
-l resources #MSUB -l resources Defines the resources that are required by the job.

See the description below for this important flag.

-N name #MSUB -N name Gives a user specified name to the job.
-o filename #MSUB -o filename Defines the file-name to be used for the standard output stream of the

batch job. By default the file with defined file name is placed under your
job submit directory. To place under a different location, expand
file name by the relative or absolute path of destination.

-q queue #MSUB -q queue Defines the queue class
-v variable=arg #MSUB -v variable=arg Expands the list of environment variables that are exported to the job
-S Shell #MSUB -S Shell Declares the shell (state path+name, e.g. /bin/bash) that interpret

the job script

-m bea #MSUB -m bea Send email when job begins (b), ends (e) or aborts (a).
-M name@uni.de #MSUB -M name@uni.de Send email to the specified email address "name@uni.de".

For cluster specific msub options, read: msub -l resource_list

The -l option is one of the most important msub options. It is used to specify a number of resource requirements for your job. Multiple resource strings are separated by commas.

msub -l resource_list
resource Purpose
-l nodes=2:ppn=16 Number of nodes and number of processes per node
-l walltime=600
-l walltime=01:30:00
Wall-clock time. Default units are seconds.

HH:MM:SS format is also accepted.

-l pmem=1000mb Maximum amount of physical memory used by any single process of the job.

Allowed units are kb, mb, gb. Be aware that processes are either MPI tasks

memory for all MPI tasks or all threads of the job.
-l advres=res_name Specifies the reservation "res_name" required to run the job.
-l naccesspolicy=policy Specifies how node resources should be accessed, e.g. -l naccesspolicy=singlejob

reserves all requested nodes for the job exclusively.
Attention, if you request nodes=1:ppn=4 together with singlejob you will be
charged for the maximum cores of the node.

Note that all compute nodes do not have SWAP space, thus DO NOT specify '-l vmem' or '-l pvmem' or your jobs will not start. msub -q queues

Queue classes define maximum resources such as walltime, nodes and processes per node and partition of the compute system. Note that queue settings of the bwHPC cluster are not identical, but differ due to their different prerequisites, such as HPC performance, scalability and throughput levels. Details can be found here:

1.3.2 msub Examples

Hint for JUSTUS users: in the following examples instead of singlenode and fat use short and long, respectively! Serial Programs

To submit a serial job that runs the script job.sh and that requires 5000 MB of main memory and 3 hours of wall clock time

a) execute:

$ msub -q singlenode -N test -l nodes=1:ppn=1,walltime=3:00:00,pmem=5000mb   job.sh

or b) add after the initial line of your script job.sh the lines (here with a high memory request):

#MSUB -l nodes=1:ppn=1
#MSUB -l walltime=3:00:00
#MSUB -l pmem=200000mb
#MSUB -N test

and execute the modified script with the command line option -q fat (with -q singlenode maximum pmem=64000mb is possible):

$ msub -q fat job.sh

Note, that msub command line options overrule script options. Multithreaded Programs

Multithreaded programs operate faster than serial programs on CPUs with multiple cores.
Moreover, multiple threads of one process share resources such as memory.
For multithreaded programs based on Open Multi-Processing (OpenMP) number of threads are defined by the environment variable OMP_NUM_THREADS. By default this variable is set to 1 (OMP_NUM_THREADS=1).
To submit a batch job called OpenMP_Test that runs a fourfold threaded program omp_executable which requires 6000 MByte of total physical memory and total wall clock time of 3 hours:

  • generate the script job_omp.sh containing the following lines:
#MSUB -l nodes=1:ppn=4
#MSUB -l walltime=3:00:00
#MSUB -l mem=6000mb
#MSUB -v EXECUTABLE=./omp_executable
#MSUB -v MODULE=<placeholder>
#MSUB -N OpenMP_Test

#Usually you should set
export KMP_AFFINITY=compact,1,0
#export KMP_AFFINITY=verbose,compact,1,0 prints messages concerning the supported affinity
#KMP_AFFINITY Description: https://software.intel.com/en-us/node/524790#KMP_AFFINITY_ENVIRONMENT_VARIABLE

module load ${MODULE}
echo "Executable ${EXECUTABLE} running on ${MOAB_PROCCOUNT} cores with ${OMP_NUM_THREADS} threads"
echo $startexe
exec $startexe

Using Intel compiler the environment variable KMP_AFFINITY switches on binding of threads to specific cores and, if necessary, replace <placeholder> with the required modulefile to enable the OpenMP environment and execute the script job_omp.sh adding the queue class singlenode as msub option:

$ msub -q singlenode job_omp.sh

Note, that msub command line options overrule script options, e.g.,

$ msub -l mem=2000mb -q singlenode job_omp.sh

overwrites the script setting of 6000 MByte with 2000 MByte. MPI Parallel Programs

MPI parallel programs run faster than serial programs on multi CPU and multi core systems. N-fold spawned processes of the MPI program, i.e., MPI tasks, run simultaneously and communicate via the Message Passing Interface (MPI) paradigm. MPI tasks do not share memory but can be spawned over different nodes.
Multiple MPI tasks can not be launched by the MPI parallel program itself but via mpirun, e.g. 4 MPI tasks of my_par_program:

$ mpirun -n 4 my_par_program

However, this given command can not be directly included in your msub command for submitting as a batch job to the compute cluster, see above.

Generate a wrapper script job_ompi.sh for OpenMPI containing the following lines:

module load mpi/openmpi/<placeholder_for_version>
# Use when loading OpenMPI in version 1.8.x
mpirun --bind-to core --map-by core -report-bindings my_par_program
# Use when loading OpenMPI in an old version 1.6.x
mpirun -bind-to-core -bycore -report-bindings my_par_program

Attention: Do NOT add mpirun options -n <number_of_processes> or any other option defining processes or nodes, since MOAB instructs mpirun about number of processes and node hostnames. Use ALWAYS the MPI options --bind-to core and --map-by core|socket|node (OpenMPI version 1.8.x). Please type mpirun --help for an explanation of the meaning of the different options of mpirun option --map-by.
Considering 4 OpenMPI tasks on a single node, each requiring 1000 MByte, and running for 1 hour, execute:

$ msub -q singlenode -l nodes=1:ppn=4,pmem=1000mb,walltime=01:00:00 job_ompi.sh

The policy on batch jobs with Intel MPI on bwUniCluster can be found here: Multithreaded + MPI parallel Programs

Multithreaded + MPI parallel programs operate faster than serial programs on multi CPUs with multiple cores. All threads of one process share resources such as memory. On the contrary MPI tasks do not share memory but can be spawned over different nodes.
Multiple MPI tasks using OpenMPI must be launched by the MPI parallel program mpirun. For multithreaded programs based on Open Multi-Processing (OpenMP) number of threads are defined by the environment variable OMP_NUM_THREADS. By default this variable is set to 1 (OMP_NUM_THREADS=1).
For OpenMPI a job-script to submit a batch job called job_ompi_omp.sh that runs a MPI program with 4 tasks and an fivefold threaded program ompi_omp_program requiring 6000 MByte of physical memory per process/thread (using 5 threads per MPI task you will get 5*6000 MByte = 30000 MByte per MPI task) and total wall clock time of 3 hours looks like:

#MSUB -l nodes=2:ppn=10
#MSUB -l walltime=03:00:00
#MSUB -l pmem=6000mb
#MSUB -v MPI_MODULE=mpi/ompi
#MSUB -v MPIRUN_OPTIONS="--bind-to core --map-by socket:PE=5 -report-bindings"
#MSUB -v EXECUTABLE=./ompi_omp_program
#MSUB -N test_ompi_omp
module load ${MPI_MODULE}
echo "${EXECUTABLE} running on ${MOAB_PROCCOUNT} cores with ${TASK_COUNT} MPI-tasks and ${OMP_NUM_THREADS} threads"
startexe="mpirun -n ${TASK_COUNT} ${MPIRUN_OPTIONS} ${EXECUTABLE}"
echo $startexe
exec $startexe

Execute the script job_ompi_omp.sh adding the queue class multinode to your msub command:

$ msub -q multinode job_ompi_omp.sh
  • With the mpirun option --bind-to core MPI tasks and OpenMP threads are bound to physical cores.
  • With the option --map-by socket:PE=<value> (neighbored) MPI tasks will be attached to different sockets and each MPI task is bound to the (in <value>) specified number of cpus. <value> must be set to ${OMP_NUM_THREADS}.
  • Old OpenMPI version 1.6.x: With the mpirun option -bind-to-core MPI tasks and OpenMP threads are bound to physical cores.
  • With the option -bysocket (neighbored) MPI tasks will be attached to different sockets and the option -cpus-per-proc <value> binds each MPI task to the (in <value>) specified number of cpus. <value> must be set to ${OMP_NUM_THREADS}.
  • The option -report-bindings shows the bindings between MPI tasks and physical cores.
  • The mpirun-options --bind-to core', --map-by socket|...|node:PE=<value> should always be used when running a multithreaded MPI program. (OpenMPI version 1.6.x: The mpirun-options -bind-to-core, -bysocket|-bynode and -cpus-per-proc <value> should always be used when running a multithreaded MPI program.)
  • The policy on batch jobs with Intel MPI + Multithreading on bwUniCluster can be found here:
    bwUniCluster: Intel MPI Parallel Programs with Multithreading Chain jobs

A job chain is a sequence of jobs where each job automatically starts its successor. Chain Job handling differs on the bwHPC Clusters. See the cluster-specific pages Interactive Jobs

Policies of interactive batch jobs are cluster specific and can be found here:

1.3.3 Handling job script options and arguments

Job script options and arguments as followed:

$ ./job.sh -n 10

can not be passed while using msub command since those will be interpreted as command line options of job.sh (like $1 = -n, $2 = 10).

Solution A:

Submit a wrapper script, e.g. wrapper.sh:

$ msub -q singlenode wrapper.sh

which simply contains all options and arguments of job.sh. The script wrapper.sh would at least contain the following lines:

./job.sh -n 10

Solution B:

Add after the header of your BASH script job.sh the following lines:

## check if $SCRIPT_FLAGS is "set"
if [ -n "${SCRIPT_FLAGS}" ] ; then
   ## but if positional parameters are already present
   ## we are going to ignore $SCRIPT_FLAGS
   if [ -z "${*}"  ] ; then
      set -- ${SCRIPT_FLAGS}

These lines modify your BASH script to read options and arguments from the environment variable $SCRIPT_FLAGS. Now submit your script job.sh as followed:

$ msub -q singlenode -v SCRIPT_FLAGS='-n 10' job.sh

1.3.4 ForHLR Batch-Jobs

1.3.5 Moab Environment Variables

Once an eligible compute jobs starts on the compute system, MOAB adds the following variables to the job's environment:

MOAB variables
Environment variables Description
MOAB_CLASS Class name
MOAB_GROUP Group name
MOAB_NODECOUNT Number of nodes allocated to job
MOAB_PARTITION Partition name the job is running in
MOAB_PROCCOUNT Number of processors allocated to job
MOAB_SUBMITDIR Directory of job submission
MOAB_USER User name

See also:

Most of all scientific programs available for HPC systems are able to extract all essential important environments at their own.
These programs identify the underlying resource management system (TORQUE/Slurm) and use the correct variables.
But a few programs still need 'msub' command line parameters like -np 'number-of-cores...' (example). In this case use TORQUE or Slurm environments only.


  • The MOAB environment variables are for your own convenience only!
  • It's not sure, the contents of the Moab variables are always accurate.
  • Do not use them in your job scripts!
  • Hence use the TORQUE or Slurm environments instead.

1.3.6 Interpreting PBS exit codes

  • The PBS Server logs and accounting logs record the ‘exit status’ of jobs.
  • Zero or positive exit status is the status of the top-level shell.
  • Certain negative exit statuses are used internally and will never be reported to the user.
  • The positive exit status values indicate which signal killed the job.
  • Depending on the system, values greater than 128 (or on some systems 256, see wait(2) or waitpid(2) for more information) are the value of the signal that killed the job.
  • To interpret (or ‘decode’) the signal contained in the exit status value, subtract the base value from the exit status.
    For example, if a job had an exit status of 143, that indicates the jobs was killed via a SIGTERM (e.g. 143 - 128 = 15, signal 15 is SIGTERM). Job termination

  • The exit code from a batch job is a standard Unix termination signal.
  • Typically, exit code 0 means successful completion.
  • Codes 1-127 are generated from the job calling exit() with a non-zero value to indicate an error.
  • Exit codes 129-255 represent jobs terminated by Unix signals.
  • Each signal has a corresponding value which is indicated in the job exit code. Job termination signals Submitting Termination Signal

Here is an example, how to 'save' a msub termination signal in a typical bwHPC-submit script.

echo "### Calling YOUR_PROGRAM command ..."
mpirun -np 'NUMBER_OF_CORES' $YOUR_PROGRAM_BIN_DIR/runproc ... (options)  2>&1
[ "$exit_code" -eq 0 ] && echo "all clean..." || echo "Executable ${YOUR_PROGRAM_BIN_DIR}/runproc finished with exit code ${$exit_code}"
  • Do not use 'time' mpirun! The exit code will be the one submitted by the first (time) program and not the msub exit code.
  • You do not need an exit $exit_code in the scripts.

1.4 Start time of job or resources : showstart

The following command can be used by any user to displays the estimated start time of a job based a number of analysis types based on historical usage, earliest available reservable resources, and priority based backlog.

1.4.1 Access

By default, this command can be run by any user.

1.4.2 Showstart Parameters

Parameter Description
DURATION Duration of pseudo-job to be checked in format [[[DD:]HH:]MM:]SS (default duration is 1 second)
-e Estimate method. By default, Moab will use the reservation based estimation method.
-f Use feedback. If specified, Moab will apply historical accuracy information to improve the quality of the estimate.
-g Grid mode. Obtain showstart information from remote resource managers. If -g is not used and Moab determines that job is already migrated, Moab obtains showstart information form the remote Moab where the job was migrated to. All resource managers can be queried by using the keyword "all" which returns all information in a table.
$ showstart -g all head.1
Estimated Start Times
[ Remote RM ] [ Reservation ] [ Priority ] [ Historical ]
[ c1 ] [ 00:15:35 ] [ ] [ ]
[ c2 ] [ 3:15:38 ] [ ] [ ]
-l qos=<QOS> Specifies what QOS the job must start under, using the same syntax as the msub command. Currently, no other resource manager extensions are supported. This flag only applies to hypothetical jobs by using the proccount[@duration] syntax.
JOBID Job to be checked
PROCCOUNT Number of processors in pseudo-job to be checked
S3JOBSPEC XML describing the job according to the Dept. of Energy Scalable Systems Software/S3 job specification.

Note: You cannot specify job flags when running showstart, and since a job by default can only run on one partition. Showstart fails when querying for a job requiring more nodes than the largest partition available.

1.4.3 Showstart Examples

  • To show estimated start time of job <job_ID> enter
$ showstart -e all <job_ID>
  • Furthermore start time of resource demands, e.g. 16 processes @ 12 h, can be displayed
$ showstart -e all 16@12:00:00
  • For a list of all options of showstart read the manpage of showstart

1.5 List of your submitted jobs : showq

Displays information about active, eligible, blocked, and/or recently completed jobs. Since the resource manager is not actually scheduling jobs, the job ordering it displays is not valid. The showq command displays the actual job ordering under the Moab Workload Manager. When used without flags, this command displays all jobs in active, idle, and non-queued states.

1.5.1 Access

By default, this command can be run by any user.
However, the -c, -i, and -r flags can only be used by Moab administrators.

1.5.2 Flags

Flag Description
-b display blocked jobs only
-c display details about recently completed jobs (see example, JOBCPURGETIME)
-g display grid job and system id's for all jobs
-i display extended details about idle jobs
-l display local/remote view. For use in a Grid environment, displays job usage of both local and remote compute resources.
-p display only jobs assigned to the specified partition
-r display extended details about active (running) jobs
-R display only jobs which overlap the specified reservation
-v Display local and full resource manager job IDs as well as partitions. If specified with the '-i' option, will display job reservation time.
-w display only jobs associated with the specified constraint. Valid constraints include user, group, acct, class, and qos.

1.5.3 Examples

These are examples as shown on the Adaptive Homepage (external links).

Showq example on the bwUniCluster for one specific user only (Name and Pop-ID is fiction. Run as MOAB-Admin.).

$ kn_jobs     # See jobs of all users from Konstanz (example)
Name         : Hans-Peter Hubndubl (1)
Login-Id     : kn_pop123456
Fachbereich  : Chemie [Theoretische und Computergestützte Chemie : Christine Peter]
Home         : /home/kn/kn_kn/kn_pop123456
Status       : angemeldet
Name         : Andreas Meisenkeiser  (50)
Login-Id     : kn_pop332211
Fachbereich  : Biologie [Evolutionary Biology : Axel Meyer]
Home         : /home/kn/kn_kn/kn_pop332211
Status       : angemeldet
$ # use UID for option in showq
$ showq -u kn_pop332211
active jobs------------------------

8370992            kn_pop33    Running     1  2:05:09:17  Wed Jan 13 15:59:01
8370991            kn_pop33    Running     1  2:05:09:17  Wed Jan 13 15:59:01
8370993            kn_pop33    Running     1  2:05:10:20  Wed Jan 13 16:00:04
8371040            kn_pop33    Running     1  2:05:11:41  Wed Jan 13 16:01:25

50 active jobs          50 of 7072 processors in use by local jobs (0.71%)
                        434 of 434 nodes active      (100.00%)

eligible jobs----------------------

0 eligible jobs   

blocked jobs-----------------------

0 blocked jobs   

Total jobs:  50
  • The summary of your active jobs shows how many jobs of yours are running, how many processors are in use by your jobs and how many nodes are in use by all active jobs.
  • Use showq -u $USER for your own jobs.
  • For further options of showq read the manpage of showq.

1.6 Shows free resources : showbf

The showbf command can be used by any user to find out how many processors are available for immediate use on the system. It is anticipated that users will use this information to submit jobs that meet these criteria and thus obtain quick job turnaround times. This command incorporates down time, reservations, and node state information in determining the available backfill window.
Note If specific information is not specified, showbf will return information for the user and group running but with global access for other credentials.

1.6.1 Access

By default, this command can be used by any user or administrator.

1.6.2 Flags

-A Show resource availability information for all users, groups, and accounts. By default, showbf uses the default user, group, and account ID of the user issuing the command.
Flag Description
-a Show resource availability information only for specified account
-d Show resource availability information for specified duration
-D Display current and future resource availability notation
-g Show resource availability information only for specified group
-h Help for this command
-L Enforce Hard limits when showing available resources
-m Allows user to specify the memory requirements for the backfill nodes of interest. It is important to note that if the optional MEMCMP and MEMORY parameters are used, they MUST be enclosed in single ticks (') to avoid interpretation by the shell. For example, enter showbf -m '==256' to request nodes with 256 MB memory.
-n Show resource availability information for a specified number of nodes. That is, this flag can be used to force showbf to display only blocks of resources with at least this many nodes available.
-p Show resource availability information for the specified partition
-q Show information for the specified QOS
-u Show resource availability information only for specified user

1.6.3 Parameters

Parameter Description
ACCOUNT Account name
CLASS Class/queue required
DURATION Time duration specified as the number of seconds or in [DD:]HH:MM:SS notation
FEATURELIST Colon separated list of node features required
GROUP Specify particular group
MEMCMP Memory comparison used with the -m flag. Valid signs are >, >=, ==, <=, and <.
MEMORY Specifies the amount of required real memory configured on the node, (in MB), used with the -m flag.
NODECOUNT Specify number of nodes for inquiry with -n flag
PARTITION Specify partition to check with -p flag
QOS Specify QOS to check with -q flag
USER Specify particular user to check with -u flag

1.6.4 Examples

  • The following command displays what resources are available for immediate use for the whole partition.
$ showbf
Partition     Tasks  Nodes      Duration   StartOffset       StartDate
---------     -----  -----  ------------  ------------  -------------- 
ALL             371    129      INFINITY      00:00:00  11:30:26_01/14
  • The request for 16 nodes can be run immediately on all partitions.
$ showbf -n 16 -d 2:00:00
Partition     Tasks  Nodes      Duration   StartOffset       StartDate
---------     -----  -----  ------------  ------------  --------------
ALL             392    132      INFINITY      00:00:00  11:35:01_01/14
  • This request for 64 nodes returned nothing, meaning it could not be fulfilled immedately.
$ showbf -n 64-d 2:00:00
Partition     Tasks  Nodes      Duration   StartOffset       StartDate
---------     -----  -----  ------------  ------------  --------------
  • The last example request displays an error message. Too much nodes requested!
$ showbf -n 256 -d 2:00:00
resources not available
  • For further options of showbf read the manpage of showbf.

1.7 Detailed job information : checkjob

Checkjob displays detailed job state information and diagnostic output for a specified job. Detailed information is available for queued, blocked, active, and recently completed jobs.

1.7.1 Access

  • End users can use checkjob to view the status of their own jobs only.
  • JobArrays and Reservations are not available on all clusters. See specific informations depending the single bwUniCluster and bwForClusters for a list of capabilities.

1.7.2 Output

Attribute Value Description
Account <STRING> Name of account associated with job
Actual Run Time [[[DD:]HH:]MM:]SS Length of time job actually ran. This info is only displayed in simulation mode.
Allocated Nodes Square bracket delimited list of node and processor ids List of nodes and processors allocated to job
Applied Nodeset** <STRING> Nodeset used for job's node allocation
Arch <STRING> Node architecture required by job
Attr Square bracket delimited list of job attributes Job Attributes (i.e. [BACKFILL][PREEMPTEE])
Available Memory** <INTEGER> The available memory requested by job. Moab displays the relative or exact value by returning a comparison symbol (>, <, >=, <=, or ==) with the value (i.e. Available Memory <= 2048).
Available Swap** <INTEGER> The available swap requested by job. Moab displays the relative or exact value by returning a comparison symbol (>, <, >=, <=, or ==) with the value (i.e. Available Swap >= 1024).
Average Utilized Procs* <FLOAT> Average load balance for a job
Avg Util Resources Per Task* <FLOAT>
BecameEligible <TIMESTAMP> The date and time when the job moved from Blocked to Eligible.
Bypass <INTEGER> Number of times a lower priority job with a later submit time ran before the job
CheckpointStartTime** [[[DD:]HH:]MM:]SS The time the job was first checkpointed
Class [<CLASS NAME> <CLASS COUNT>] Name of class/queue required by job and number of class initiators required per task.
Dedicated Resources Per Task* Space-delimited list of <STRING>:<INTEGER> Resources dedicated to a job on a per-task basis
Disk <INTEGER> Amount of local disk required by job (in MB)
Estimated Walltime [[[DD:]HH:]MM:]SS The scheduler's estimated walltime. In simulation mode, it is the actual walltime.
EnvVariables** Comma-delimited list of <STRING> List of environment variables assigned to job
Exec Size* <INTEGER> Size of job executable (in MB)
Executable <STRING> Name of command to run
Features Square bracket delimited list of <STRING>s Node features required by job
Group <STRING> Name of UNIX group associated with job
Holds Zero or more of User, System, and Batch Types of job holds currently applied to job
Image Size <INTEGER> Size of job data (in MB)
IWD (Initial Working Directory) <DIR> Directory to run the executable in
Job Messages** <STRING> Messages attached to a job
Job Submission** <STRING> Job script submitted to RM
Memory <INTEGER> Amount of real memory required per node (in MB)
Max Util Resources Per Task* <FLOAT>
Nodecount <INTEGER> Number of nodes required by job
Opsys <STRING> Node operating system required by job
Partition Mask ALL or colon delimited list of partitions List of partitions the job has access to
PE <FLOAT> Number of processor-equivalents requested by job
Per Partition Priority** Tabular Table showing job template priority for each partition
Priority Analysis** Tabular Table showing how job's priority was calculated:
Job PRIORITY* Cred( User:Group:Class) Serv(QTime)
QOS <STRING> Quality of Service associated with job
Reservation <RSVID ( <TIME1 - <TIME2> Duration: <TIME3>) RESID specifies the reservation id, TIME1 is the relative start time, TIME2 the relative end time
TIME3 The duration of the reservation
Req [<INTEGER>] TaskCount: <INTEGER> Partition: <partition> A job requirement for a single type of resource followed by the number of tasks instances required and the appropriate partition
StartCount <INTEGER> Number of times job has been started by Moab
StartPriority <INTEGER> Start priority of job
StartTime Time job was started by the resource management system
State One of Idle, Starting, Running, etc Current Job State
SubmitTime Time job was submitted to resource management system
Swap <INTEGER> Amount of swap disk required by job (in MB)
Task Distribution* Square bracket delimited list of nodes
Time Queued
Total Requested Nodes** <INTEGER> Number of nodes the job requested
Total Requested Tasks <INTEGER> Number of tasks requested by job
User <STRING> Name of user submitting job
Utilized Resources Per Task* <FLOAT>
WallTime [[[DD:]HH:]MM:]SS of [[[DD:]HH:]MM:]SS Length of time job has been running out of the specified limit

In the above table, fields marked with an asterisk (*) are only displayed when set or when the -v flag is specified. Fields marked with two asterisks (**) are only displayed when set or when the -v -v flag is specified.

1.7.3 Arguments

Argument Format Default Description Example
--flags --flags=future (none) Evaluates future eligibility of job (ignore current resource state and usage limitations)
$ checkjob -v --flags=future 8370992
Display reasons why idle job is blocked ignoring node state and current node utilization constraints.
-l (Policy level) <POLICYLEVEL> HARD, SOFT, or OFF (none) Reports job start eligibility subject to specified throttling policy level.
$ checkjob -l SOFT 8370992
$ checkjob -l HARD 8370992
-n (NodeID) <NODEID> (none) Checks job access to specified node and preemption status with regards to jobs located on that node.
checkjob -n uc1n320 8370992
-r (Reservation) <RSVID> (none) Checks job access to specified reservation <RSVID>.
checkjob -r rainer_kn_resa.1 8370992
-v (Verbose) (n/a) Sets verbose mode. If the job is part of an array, the -v option shows pertinent array information before the job-specific information. Specifying the double verbose ("-v -v") displays additional information about the job. See more infos here!
checkjob -v 8370992

8370992 = JobId (see examples above)

1.7.4 Parameters

Parameters, descriptions (a lot!) and examples can be found in Adaptive documentation page.

  • For further options of checkjob see the manual page of checkjob
    $ man checkjob

1.7.5 Checkjob Examples

Here is an example from the bwUniCluster.

showq -u $USER   # show my own jobs
active jobs------------------------
8370992            kn_popnn    Running     1  2:03:56:50  Wed Jan 13 15:59:01
8370991            kn_popnn    Running     1  2:03:56:50  Wed Jan 13 15:59:01
8371040            kn_popnn    Running     1  2:03:59:14  Wed Jan 13 16:01:25

49 active jobs          49 of 7072 processors in use by local jobs (0.69%)
                        434 of 434 nodes active      (100.00%)
eligible jobs----------------------
0 eligible jobs   

blocked jobs-----------------------
0 blocked jobs   

Total jobs:  49
$ # now, see what's up with the first job in my queue
$ checkjob 8370992
job 8370992

AName: Nic_cit_09_Apo_zal_07_cl2_07_cl3_07_cl5_07_2.moab
State: Running 
Creds:  user:kn_pop'nnnnn'  group:kn_kn  account:konstanz  class:singlenode
WallTime:   20:04:28 of 3:00:00:00
BecameEligible: Wed Jan 13 15:58:11
SubmitTime: Wed Jan 13 15:57:58
  (Time Queued  Total: 00:01:03  Eligible: 00:00:58)

StartTime: Wed Jan 13 15:59:01
TemplateSets:  DEFAULT
NodeMatchPolicy: EXACTNODE
Total Requested Tasks: 1

Req[0]  TaskCount: 1  Partition: uc1
Memory >= 4000M  Disk >= 0  Swap >= 0
Dedicated Resources Per Task: PROCS: 1  MEM: 4000M

Allocated Nodes:

SystemID:   uc1
SystemJID:  8370992

IWD:            /pfs/data2/home/kn/kn_kn/kn_pop139522/fastsimcoal25/Midas_RAD_anchored/Nic_cit_09_Apo_zal_07_cl2_07_cl3_07_cl5_07/1col_DIV-resize_admix_zal1st_starlike_cl2-base_CL-growths_GL-bottlegrowth_onlyintramig/new_est/run_2
SubmitDir:      /pfs/data2/home/kn/kn_kn/kn_pop139522/fastsimcoal25/Midas_RAD_anchored/Nic_cit_09_Apo_zal_07_cl2_07_cl3_07_cl5_07/1col_DIV-resize_admix_zal1st_starlike_cl2-base_CL-growths_GL-bottlegrowth_onlyintramig/new_est/run_2
Executable:     /opt/moab/spool/moab.job.voNyde

StartCount:     1
BypassCount:    1
Partition List: uc1
StartPriority:  -3692
PE:             1.00
Reservation '8370992' (-20:04:34 -> 2:03:55:26  Duration: 3:00:00:00)

You can use standard Linux pipe commands to filter the very detailed checkjob output.

  • Is the job still running?
$ checkjob 8370992 | grep ^State
State: Running 
  • Write your own checkjob wrapper to modify the checkjob output to have it all one's own way. Here's an example (cut/paste it if you'd like to use this one):
# cj Display Moab-Jobstatus (checkjob wrapper)
# 'rainer.rutka@uni-konstanz.de "2015-09-21 ~1.1
# $1 = Moab Job-Nummer, $2 = Sleep-Time in seconds
shopt -s extglob        # "+"-Zeichen/Integerpruefung

rev=$(tput rev)
res=$(tput sgr0)
resc=$(tput setf 0)
gruen=$(tput setf 2)
rot=$(tput setf 4)

[ "$1" == "-h" ] && { echo "usage: $(basename "$0") (int)Moab-Job-Number [(int)Intervall/Sekunden(Default:30s)]"; exit 0; }
[ "$1" ] || { echo "Moab-Jobnummer fehlt..."; exit 1; } && { jobid="$1"; }
[ ! -z "${jobid##+([0-9])}" ] && { echo "<${jobid}> ist keine Zahl!"; exit 1; }
[ "$2" ] && { let schlaf="$2"; } || { let schlaf=30; }
[ ! -z "${2##+([0-9])}" ] && { echo "<${2}> ist keine Zahl!"; exit 1; }

let sekunden=0
let von=1
let bis=73
let rechts=1
pos () { tput cup ${1} ${2}; }

dauer () {
   pos 0 90
   let gesamt=$[$sekunden*$schlaf]
   pos 0 38
    echo 'Wartezeit:'
   [ "$gesamt" -lt 60 ] && { pos 0 49; echo "${gruen}${gesamt}s${resc}"; }
   [ "$gesamt" -ge 60 ] && { pos 0 49; echo "${gruen}$[$gesamt / 60]m$[$gesamt % 60]s ${resc}"; 
   [ "$gesamt" -ge 3600 ] && { pos 0 49; echo "${gruen}$[$gesamt / 3600]h$[$gesamt % 3600 / 60]m$[$gesamt % 60]s ${resc}"; }

checkit () {
   tput clear
   pos 0 1
   echo "${resc}Job: ${gruen}${jobid}${resc} Status: "
   pos 0 60
   echo "Intervall: ${schlaf}s"

   pos 1 1
   echo '>'

   while true
      status=$(checkjob ${jobid} | grep ^State:)
      pos 0 22
      echo "<${rot}${status/State:}${resc}>" 
      [ "${status/State:}" == "" ] && { let sekunden=0; echo "${rot} ERROR! ${resc}"; exit 1; }
      [ "${status/State:}" == " Completed " ] && { echo "${gruen} Job ${jobid} ist fertig!${resc}"; exit 0; }
      [ "${status/State:}" == " Removed " ] && { echo "${rot} Job ${jobid} wurde gelöscht!${resc}"; exit 1; }
      [ "$rechts" == "$bis" ] && { let rechts="$von"; checkit ${jobid} ${schlaf} ; } || let rechts++
      pos 1 $rechts
      sleep ${schlaf}
      echo -n .
      let sekunden++;
checkit ${*}

Using the same Job-ID as above the output of the script (named 'cj'):

$ cj -h
usage: cj (int)Moab-Job-Number [(int)Intervall/Sekunden(Default:30s)]
$ cj 8370992 10 # update every 10 seconds
 Job: 8370992 Status: < Running >     Wartezeit: 30m50s     Intervall: 10s

1.8 Blocked job information : checkjob -v

This command allows to check the detailed status and resource requirements of your active, queued, or recently completed job. Additionally, this command performs numerous diagnostic checks and determines if and where the job could potentially run. Diagnostic checks include policy violations, reservation constraints, preemption status, and job to resource mapping. If a job cannot run, a text reason is provided along with a summary of how many nodes are and are not available. If the -v flag is specified, a node by node summary of resource availability will be displayed for idle jobs.

If your job is blocked do not delete it!

1.8.1 Job Eligibility

If a job cannot run, a text reason is provided along with a summary of how many nodes are and are not available. If the -v flag is specified, a node by node summary of resource availability will be displayed for idle jobs. For job level eligibility issues, one of the following reasons will be given:

Reason Description
job has hold in place one or more job holds are currently in place
insufficient idle procs there are currently not adequate processor resources available to start the job
idle procs do not meet requirements adequate idle processors are available but these do not meet job requirements
start date not reached job has specified a minimum start date which is still in the future
expected state is not idle job is in an unexpected state
state is not idle job is not in the idle state
dependency is not met job depends on another job reaching a certain state
rejected by policy job start is prevented by a throttling policy

If a job cannot run on a particular node, one of the following 'per node' reasons will be given:

Description Reason
Class Node does not allow required job class/queue
CPU Node does not possess required processors
Disk Node does not possess required local disk
Features Node does not possess required node features
Memory Node does not possess required real memory
Network Node does not possess required network interface
State Node is not Idle or Running

1.8.2 Example

A blocked job has hit a limit and will become idle if resource get free. The "-v (verbose)" mode of 'checkjob' also shows a message "BLOCK MSG:" for more details.

checkjob -v 8370992

 BLOCK MSG: job <jobID> violates active SOFT MAXPROC limit of 750 for acct mannheim
  partition ALL (Req: 160  InUse: 742) (recorded at last scheduling iteration)

In this case the job has reached the account limit of mannheim while requesting 160 core when 742 were already in use.
The most common cause of blocked jobs is a violation of MAXPROC or MAXPS limits, indicating that your group has scheduled too many outstanding processor seconds at the same time.

1.8.3 The Limits imposed by the Scheduler

This refers to limits on the number of jobs in the queue which are enforced by the scheduler. The largest factors in determining limits in numbers of jobs are the Maximum Processor Seconds (MAXPS) and the Maximum Processors (MAXPROC) for each account. The MAXPS is the total number of processor core seconds (ps) allocated for each (group) account. It is based on fairshare values in dependency of the configured values for your <OE> (Konstanz, Ulm, etc. ...) .
Users can submit as many jobs but they cannot be scheduled to run if their groups MAXPROC or MAXPS value is exceeded. They instead enter into a "HOLD" state. If the limits of the group is not reached but the resources are not available, the jobs enter into "IDLE" state and will run once the requested resources become available.

1.9 Canceling own jobs : canceljob

Caution: This command is deprecated. Use mjobctl -c instead!

The canceljob <JobId> command is used to selectively cancel the specified job(s) (active, idle, or non-queued) from the queue.
Note that only own jobs can be cancelled.

1.9.1 Access

This command can be run by any Moab Administrator and by the owner of the job.

Flag Name Format Default Description Example
-h HELP n./a. Display usage information
$ canceljob -h
JOB ID <STRING> (none) a jobid, a job expression, or the keyword 'ALL' see: example use of canceljob

1.9.2 Example Use of Canceljob

Example use of canceljob run on the bwUniCluster

[...calc_repo-0]$ msub bwhpc-fasta-example.moab
8374356              # this is the JobId
$ checkjob 8374356
job 8374356
AName: fasta36_job
State: Idle 
Creds:  user:kn_pop235844  group:kn_kn  account:konstanz  class:multinode
WallTime:   00:00:00 of 00:10:00
BecameEligible: Fri Jan 15 12:10:53
SubmitTime: Fri Jan 15 12:10:43
  (Time Queued  Total: 00:00:10  Eligible: 00:00:08)

$ checkjob 8374356 | grep ^State:
State: Idle              # state is 'Idle'

$ # now cancel the job
$ canceljob 8374356
job '8374356' cancelled

$ checkjob 8374356 | grep ^State:
State: Removed      # state turned into 'Removed'

1.10 Moab Job Control : mjobctl

The mjobctl command controls various aspects of jobs. It is used to submit, cancel, execute, and checkpoint jobs. It can also display diagnostic information about your own jobs.

1.10.1 Canceling own jobs : mjobctl -c

If you want to cancel a job that has been submitted, please do not use the PBS/Torque qdel (n./a.) or the deprecated canceljob commands.
Instead, use mjobctl -c <jobid>.

Flag Format Default Description Example
-cl JobId (none) Cancel a job. see: example use of mjobctl -c Example Use of mjobctl -c

Canceling a job on the bwUniCluster

[...-calc_repo-0]$ msub bwhpc-fasta-example.moab

$ checkjob 8374426 | grep ^State
State: Idle                # job is 'Idle'

$ mjobctl -c 8374426
job '8374426' cancelled    # job is cancelled

checkjob 8374426 | grep ^State
State: Removed             # now, job is removed

$ # my own checkjob wrapper
cj 8374426
 Job: 8374426 Status: < Removed >     Wartezeit: 1m30s         Intervall: 30s
 Job 8374426 wurde gelöscht!
$ E-Mail notification of mjobctl -c

You will receive an e-mail notification like this one (example with Slurm)

From: slurm@uc1-sv1.scc.kit.edu
Subject: SLURM Job_id= 8374426 Name=fasta36_job Ended, Run time 00:01:30, CANCELLED, ExitCode 0

from the resource manager shortly after the job was removed from the queue.

You need to add these MOAB environments into your submit script or command line parameters for the msub command:

#MSUB -m ae
#MSUB -M e-mail@FQDN (e-mail address like: name@domain.de)
msub -m option(s)
Option Description
-m option(s) Defines the set of conditions (a=abort | b=begin | e=end) when the server will send a mail message about the job to the user.
-N name Gives a user specified name to the job. Note that job names do not appear in all MOAB job info displays, and do not determine how your jobs stdout/stderr files are named.

1.10.2 Other Mjobctl-Options

See also:

Not all of the listed options are available for 'normal' users. Some are for MOAB-admins only.

2 Resource Managers

2.1 TORQUE Resource Manager

The Terascale Open-source Resource and QUEue Manager (TORQUE) is a distributed resource manager providing control over batch jobs and distributed compute nodes. TORQUE can integrate with the Moab Workload Manager to improve overall utilization, scheduling and administration on a HPC-C4 cluster.

2.1.1 Batch Job (PBS) Variables : bwForCluster

At the time a job is launched into execution, TORQUE defines multiple environment variables, which can be used from within the submission script to define the correct workflow of the job.
Since the work load manager TORQUE on BwForCluster_Chemistry uses the resource manager TORQUE, the following environment variables of TORQUE are added to your environment once your job has started (excerpt of the most important ones).

Environment Brief explanation
PBS_O_WORKDIR Directory where the qsub command is issued (Job's submission directory)
PBS_O_SHELL Script shell
PBS_O_PATH Path variable used to locate executables within job script
PBS_O_HOST Host on which job script is currently running
PBS_O_HOME Home directory of submitting user
PBS_O_LOGNAME Name of submitting user
PBS_NODEFILE File that lists the hosts (compute nodes) on which the job is run. Line delimited.
PBS_JOBNAME User specified jobname
PBS_NODENUM Node offset number
PBS_NUM_NODES Number of nodes allocated to the job
PBS_QUEUE Job queue
PBS_NP Number of execution slots (cores) for the job
PBS_NUM_PPN Number of procs per node allocated to the job
PBS_JOBID Unique number PBS assigns to a job
PBS_TASKNUM Number of tasks requested
TMPDIR Directory on the scratch (local and fast) disk space that is unique to a job
  • PBS_O_WORKDIR is typically used at the beginning of a script to go to the directory where the qsub command was issued, which is frequently also the directory containing the input data for the job, etc. The typical use is
    inside a submission script.
  • PBS_NODEFILE is typically used to define the environment for the parallel run, for mpirun in particular. Normally, this usage is hidden from users inside a script (e.g. enable_arcus_mpi.sh), which defines the environment for the user.
  • PBS_JOBID is useful to tag job specific files and directories, typically output files or run directories. For instance, the submission script line
    myApp > $PBS_JOBID.out
    runs the application myApp and redirects the standard output to a file whose name is given by the job id. (NB: the job id is a number assigned by Torque and differs from the character string name given to the job in the submission script by the user.)
  • TMPDIR is the name of a scratch disk directory unique to the job. The scratch disk space typically has faster access than the disk space where the user home and data areas reside and benefits applications that have a sustained and large amount of I/O. Such a job normally involves copying the input files to the scratch space, running the application on scratch and copying the results to the submission directory.

See also:

2.1.2 Job Exit Status

Once a job under TORQUE has completed, the exit_status attribute will contain the result code returned by the job script. This attribute can be seen by submitting a qstat -f command to show the entire set of information associated with a job. The exit_status field is found near the bottom of the set of output lines.

$ msub bwforcluster-quantum-example.moab
$ qstat
Job ID                    Name             User            Time Use S Queue
------------------------- ---------------- --------------- -------- - -----
760236.adm01               ...-example.moab kn_l_pop235844  00:00:00 C short          
$ qstat -f 760236
Job Id: 760236.adm01
    Job_Name = bwforcluster-quantum-example.moab
    Job_Owner = kn_l_pop235844@adm01
    resources_used.cput = 00:00:00
    resources_used.mem = 0kb
    resources_used.vmem = 0kb
    resources_used.walltime = 00:00:11
    job_state = C
    queue = short
    server = adm01
    Checkpoint = u
    ctime = Fri Jan 15 10:10:23 2016
    Error_Path = adm01:/nfs/home1/kn/kn_kn/kn_l_pop235844/src/chem/quantum_esp
    exec_host = n0301/0
    exec_port = 15003
    group_list = kn_kn
    Hold_Types = n
    Join_Path = oe
    Keep_Files = n
    Mail_Points = a
    mtime = Fri Jan 15 10:10:44 2016
    Output_Path = adm01:/nfs/home1/kn/kn_kn/kn_l_pop235844/src/chem/quantum_es
    Priority = 0
    qtime = Fri Jan 15 10:10:23 2016
    Rerunable = False
    Resource_List.mem = 4000mb
    Resource_List.nodect = 1
    Resource_List.nodes = 1:ppn=1
    Resource_List.walltime = 48:00:00
    session_id = 1349
    Variable_List = MOAB_BATCH=,MOAB_CLASS=short,MOAB_GROUP=kn_kn,
    euser = kn_l_pop235844
    egroup = kn_kn
    queue_type = E
    etime = Fri Jan 15 10:10:23 2016
--> exit_status = 0

    start_time = Fri Jan 15 10:10:33 2016
    start_count = 1
    fault_tolerant = False
    comp_time = Fri Jan 15 10:10:45 2016
    job_radix = 0
    total_runtime = 14.439113
    proxy_user = kn_l_pop235844
    submit_host = adm01
    job_id = 760236
    x = ENVREQUESTED:TRUE;SID:Moab;SJID:760236;SRMJID:760236

This code can be useful in diagnosing problems with jobs that may have unexpectedly terminated.
If TORQUE was unable to start the job, this field will contain a negative number produced by the pbs_mom.
Otherwise, if the job script was successfully started, the value in this field will be the return value of the script. TORQUE Supplied Exit Codes

Name Value Description
JOB_EXEC_OK 0 job exec successful
JOB_EXEC_FAIL1 -1 job exec failed, before files, no retry
JOB_EXEC_FAIL2 -2 job exec failed, after files, no retry
JOB_EXEC_RETRY -3 job execution failed, do retry
JOB_EXEC_INITABT -4 job aborted on MOM initialization
JOB_EXEC_INITRST -5 job aborted on MOM init, chkpt, no migrate
JOB_EXEC_INITRMG -6 job aborted on MOM init, chkpt, ok migrate
JOB_EXEC_BADRESRT -7 job restart failed
JOB_EXEC_CMDFAIL -8 exec() of user command failed

2.2 Slurm Resource Manager

The Slurm Resource and Workload Manager (formerly known as Simple Linux Utility for Resource Management (see: SLURM)) is a free and open-source job scheduler.

2.2.1 Batch Job (Slurm) Variables : bwUniCluster

Since the work load manager MOAB on bwUniCluster uses the resource manager Slurm, the following environment variables of Slurm are added to your environment once your job has started (only an excerpt of the most important ones).

Environment Brief explanation
SLURM_JOB_CPUS_PER_NODE Number of processes per node dedicated to the job
SLURM_JOB_NODELIST List of nodes dedicated to the job
SLURM_JOB_NUM_NODES Number of nodes dedicated to the job
SLURM_MEM_PER_NODE Memory per node dedicated to the job
SLURM_NPROCS Total number of processes dedicated to the job
SLURM_CLUSTER_NAME Name of the cluster executing the job
SLURM_CPUS_PER_TASK Number of CPUs requested per task
SLURM_JOB_PARTITION Partition/queue running the job
SLURM_JOB_UID User ID of the job's owner
SLURM_JOB_USER User name of the job's owner
SLURM_RESTART_COUNT Number of times job has restarted
SLURM_STEP_NUM_TASKS Task count (number of PI ranks)

See also:

2.2.2 Job Exit Codes

A job's exit code (aka exit status, return code and completion code) is captured by SLURM and saved as part of the job record.
Any non-zero exit code will be assumed to be a job failure and will result in a Job State of FAILED with a reason of "NonZeroExitCode".
The exit code is an 8 bit unsigned number ranging between 0 and 255. While it is possible for a job to return a negative exit code, SLURM will display it as an unsigned value in the 0 - 255 range. Displaying Exit Codes and Signals

SLURM displays a job's exit code in the output of the scontrol show job and the sview utility. SLURM displays job step exit codes in the output of the scontrol show step and the sview utility.
When a signal was responsible for a job or step's termination, the signal number will be displayed after the exit code, delineated by a colon(:).