cbatch - Submit Batch Job¶
cbatch submits a batch script describing the entire computation process to the job scheduling system, assigns a job ID, and waits for the scheduler to allocate resources and execute it.
The CraneSched system requires users and accounts before submitting jobs. Please refer to the cacctmgr tutorial for adding users and accounts.
Quick Start¶
Here's a simple single-node job example:
The following job requests one node, one CPU core, and runs hostname on the compute node before exiting:
#!/bin/bash
#CBATCH --ntasks-per-node 1
#CBATCH --nodes 1
#CBATCH -c 1
#CBATCH --mem 20M
#CBATCH --time 0:3:1
#CBATCH -o job.out
#CBATCH -p CPU
#CBATCH -J Test_Job
hostname
Assuming the job script is saved as cbatch_test.sh, submit it using:
cbatch Execution Results


Command Line Options¶
Resource Specifications¶
- -N, --nodes uint32: Number of nodes to run the job (default: 1)
- -c, --cpus-per-task float: Number of CPU cores required per task (default: 1)
- --ntasks-per-node uint32: Number of tasks to invoke on each node (default: 1)
- --mem string: Maximum amount of real memory. Supports GB (G, g), MB (M, m), KB (K, k) and Bytes (B), default unit is MB
- --gres string: Generic resources required per task, format:
gpu:a100:1orgpu:1 - --L, --licenses: The licenses that the job requires to use, format:
lic1:2,lic2:4orlic1:2|lic2:4
Job Information¶
- -J, --job-name string: Name of the job
- -A, --account string: Account for job submission
- -p, --partition string: Requested partition
- -q, --qos string: Quality of Service (QoS) used for the job
- -t, --time string: Time limit, format:
day-hours:minutes:seconds(e.g.,5-0:0:1for 5 days, 1 second) orhours:minutes:seconds(e.g.,10:1:2for 10 hours, 1 minute, 2 seconds) - --comment string: Comment for the job
Node Selection¶
- -w, --nodelist string: Nodes to be allocated to the job (comma separated list)
- -x, --exclude string: Exclude specific nodes from allocation (comma separated list)
I/O Redirection¶
- -o, --output string: Redirect script standard output path
- -e, --error string: Redirect script error log path
- --open-mode string: Mode for opening output and error files. Supported values:
append,truncate(default)
Environment Variables¶
- --get-user-env: Load user's login environment variables
- --export string: Propagate environment variables
Scheduling Options¶
- --begin string: Start time for the job. Format:
YYYY-MM-DDTHH:MM:SS - --exclusive: Request exclusive node resources
- -H, --hold: Submit job in held state
- -r, --reservation string: Use reserved resources
Email Notifications¶
- --mail-type string: Notify user by mail when certain events occur. Supported values:
NONE,BEGIN,END,FAIL,TIMELIMIT,ALL(default:NONE) - --mail-user string: Mail address of notification receiver
Container Support¶
- --container string: Path to container image
- --interpreter string: Specify script interpreter (e.g.,
/bin/bash,/usr/bin/python3)
Miscellaneous¶
- -D, --chdir string: Working directory of the job
- --extra-attr string: Extra attributes of the job (JSON format)
- --repeat uint32: Submit job multiple times (default: 1)
- --wrap string: Wrap command string in a shell script and submit
- --json: Output in JSON format
- -C, --config string: Path to configuration file (default:
/etc/crane/config.yaml) - -h, --help: Display help information
- -v, --version: Display cbatch version
Usage Examples¶
Basic Job Submission¶
Submit a batch script:
Help Information¶
Display help:
Specify Account¶
Submit job with a specific account:
Node Exclusion¶
Exclude nodes from allocation:
Job Name¶
Specify job name:
Node Selection¶
Request specific nodes:
Partition Selection¶
Submit to specific partition:
Time Limit¶
Set time limit:
CPU Cores¶
Request specific number of CPU cores:
Memory Specification¶
Specify memory requirements:
Multi-node Jobs¶
Request multiple nodes with tasks per node:
Working Directory¶
Specify working directory:
Error Log¶
Redirect error output:
Environment Variables¶
Export all environment variables:
User Environment¶
Load user's login environment:
Output Redirection¶
Redirect standard output:
Quality of Service¶
Specify QoS:
Repeat Submission¶
Submit job multiple times:
Environment Variables¶
Common environment variables available in batch scripts:
| Variable | Description |
|---|---|
| CRANE_JOB_NODELIST | List of allocated nodes |
| %j | Job ID (for use in file patterns) |
Multi-node Parallel Jobs¶
Here's an example of submitting a multi-node, multi-core job:
The following job runs on three nodes, using 4 CPU cores per node:
#!/bin/bash
#CBATCH -o crane_test%j.out
#CBATCH -p CPU
#CBATCH -J "crane_test"
#CBATCH --nodes 3
#CBATCH --ntasks-per-node 4
#CBATCH -c 4
#CBATCH --time 50:00:00
# Generate machine file from allocated nodes
echo "$CRANE_JOB_NODELIST" | tr ";" "\n" > crane.hosts
# Load MPI runtime environment
module load mpich/4.0
# Execute cross-node parallel task
mpirun -n 13 -machinefile crane.hosts helloWorld > log
Advanced Features¶
Container Support¶
Submit a job that runs in a container:
Delayed Start¶
Schedule a job to start at a specific time:
Held Jobs¶
Submit a job in held state:
Release the held job using ccontrol release <job_id>.
Email Notifications¶
Receive email notifications:
JSON Output¶
Get submission result in JSON format:
Wrap Command¶
Submit a simple command without creating a script file: