agentleFS
AI-ModConAI-ModCon/genesis-skills/skills/hpc-skills/pbs/SKILL.md

pbs

Skill30 starsChanged 51 days agoBSD-2-ClauseView on GitHub

PBS/OpenPBS job scheduler for HPC batch job scheduling. Use when submitting batch or interactive jobs with qsub, monitoring with qstat, deleting with qdel, writing #PBS job scripts, specifying resources with the select/ncpus/ mem/ngpus syntax, setting walltime, working with job arrays (-t flag), setting dependencies with -W depend=, checking job accounting, or troubleshooting jobs on any PBS or OpenPBS cluster.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always load modules inside the job script, not just in your login shell.

    line 258

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PBS / OpenPBS Job Scheduler

PBS (Portable Batch System) is widely used at DOE labs (ALCF, etc.) and many academic HPC centers. Jobs are described with #PBS directives and submitted via qsub.

Quick Command Reference

CommandPurpose
qsub script.shSubmit a batch job script
qsub -IStart an interactive job
qstatView job queue
qstat -f <id>Full job detail
qdel <id>Delete/cancel a job
qhold <id>Place a user hold on a job
qrls <id>Release a held job
qalter <id>Modify a pending job
pbsnodes -aList all nodes and their state
qstat -QList available queues

Job State Codes

CodeStateMeaning
QQueuedWaiting for resources
RRunningCurrently executing
HHeldHeld by user, operator, or system
EExitingJob is finishing/cleaning up
CCompletedFinished (may appear briefly)
FFinishedJob is done (in history)
SSuspendedTemporarily suspended
WWaitingWaiting for eligible start time (-a)

Writing Job Scripts

#PBS directives must appear before any non-comment executable line.

Minimal working script:

#!/bin/bash
#PBS -N myjob
#PBS -A myproject
#PBS -l select=1:ncpus=32:mem=64gb
#PBS -l walltime=01:00:00
#PBS -o myjob.out
#PBS -e myjob.err
#PBS -q workq

cd $PBS_O_WORKDIR
module load gcc openmpi
mpiexec -n 32 ./my_application

Key #PBS Directives

DirectiveExampleNotes
-NmyjobJob name
-AmyprojectAccount/project (often mandatory)
-l select=...2:ncpus=128:mem=256gbResource selection (see below)
-l walltime=02:30:00Wall clock limit (HH:MM:SS)
-qworkqQueue/destination
-ojob.outStdout path
-ejob.errStderr path
-j oe—Merge stdout+stderr into one file
-m abe—Email on abort/begin/end
-Muser@host.eduEmail address
-V—Export all current env vars to job
-v VAR=valNPROCS=8Export specific variable
-r n—Job is not rerunnable
-a202501011400Eligible start time (CCYYMMDDhhmm)
-W depend=afterok:12345Job dependency
-t1-100Job array (see below)

Resource Select Syntax

-l select=<N>:<property>=<value>:... where N is the number of "chunks" (typically nodes).

# 1 node, 16 CPUs, 32 GB RAM
#PBS -l select=1:ncpus=16:mem=32gb

# 4 nodes, 128 CPUs each, 2 GPUs each
#PBS -l select=4:ncpus=128:mem=256gb:ngpus=2

# MPI + OpenMP hybrid (mpiprocs = MPI ranks per chunk)
#PBS -l select=2:ncpus=64:mpiprocs=4:ompthreads=16:mem=128gb

# Request specific node features
#PBS -l select=1:ncpus=32:arch=broadwell

place directive controls layout:

#PBS -l place=scatter          # one chunk per node (default)
#PBS -l place=pack             # pack chunks onto fewest nodes
#PBS -l place=excl             # exclusive node access
#PBS -l place=scatter:excl     # one per node, exclusive

Submitting Jobs

# Batch submission
qsub script.sh

# Override directives at submission
qsub -l select=4 -l walltime=2:00:00 script.sh

# Interactive job (drops into shell on allocated node)
qsub -I -l select=1:ncpus=8 -l walltime=1:00:00 -q debug

# Interactive with environment exported
qsub -I -V -l select=1:ncpus=16:mem=32gb -l walltime=2:00:00

Monitoring Jobs

# All your jobs
qstat -u $USER

# All running jobs
qstat -r

# All queued/held jobs
qstat -i

# Full detail for one job
qstat -f 12345

# Finished job details (past ~7 days, if server configured)
qstat -xf 12345

# Estimated start times
qstat -T

# List queues and their limits
qstat -Q

# All node states
pbsnodes -a

Default output file locations (when -o/-e not specified):

  • Stdout: <jobname>.o<jobid> in $PBS_O_WORKDIR
  • Stderr: <jobname>.e<jobid> in $PBS_O_WORKDIR

Watch a running job's output:

tail -f myjob.o12345

Cancelling, Holding, and Modifying Jobs

qdel 12345                    # cancel job
qdel 12345[5]                 # cancel array element 5
qdel -W force 12345           # force delete (if qdel hangs)

qhold 12345                   # place user hold (state → H)
qrls 12345                    # release hold

qalter -l walltime=4:00:00 12345   # extend walltime (if pending)
qalter -l select=8 12345           # change node count (if pending)

Job Arrays

Submit many similar jobs from one qsub. Resources apply to each array element independently.

# In the script:
#PBS -t 1-100            # indices 1..100
#PBS -t 1-50:2           # odd indices 1,3,5,...,49
#PBS -t 1-100%10         # max 10 running simultaneously

Or at submission: qsub -t 1-100 script.sh

Inside the script, use $PBS_ARRAY_INDEX:

INPUT="data/input_${PBS_ARRAY_INDEX}.txt"
mpiexec ./process "$INPUT"

Array management:

qstat -t 12345            # show all elements
qdel 12345[]              # delete entire array
qdel 12345[5]             # delete element 5

Job Dependencies

# Submit job1, capture ID
JOB1=$(qsub stage1.sh)

# Submit job2 to run only if job1 succeeds
qsub -W depend=afterok:$JOB1 stage2.sh

# Common dependency types:
# afterok:<id>     — start if <id> exits with code 0
# afternotok:<id>  — start if <id> exits with non-zero code
# afterany:<id>    — start regardless of <id> outcome
# before:<id>      — <id> starts only after this job begins
# beforeok:<id>    — <id> starts only if this job succeeds

Common Environment Variables (Inside a Job)

VariableValue
$PBS_JOBIDFull job ID (e.g., 12345.server)
$PBS_JOBNAMEJob name
$PBS_O_WORKDIRDirectory where qsub was run
$PBS_O_HOSTHost where qsub was run
$PBS_NODEFILEFile listing allocated nodes (for MPI)
$PBS_NPTotal number of CPUs/tasks
$PBS_NUM_NODESNumber of nodes
$PBS_QUEUEQueue name
$PBS_ARRAY_INDEXArray task index (array jobs only)
$PBS_ARRAY_IDParent array job ID

Using $PBS_NODEFILE with MPI:

mpiexec -hostfile $PBS_NODEFILE -n $PBS_NP ./my_app
# or simply:
mpiexec -n $PBS_NP ./my_app   # if MPI is PBS-aware

Module System

module avail              # list available modules
module spider <pkg>       # search for a package
module load gcc/12 openmpi/4.1
module list               # show loaded modules
module purge              # unload everything

Always load modules inside the job script, not just in your login shell.

Additional Resources

  • Annotated job script examples: references/job-scripts.md
  • Monitoring, qstat field glossary, troubleshooting: references/job-control.md
  • Full resource select and place reference: references/resource-spec.md
  • Copy-paste templates: assets/templates/

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.