Submitting Jobs via Slurm
Prerequisites
Access Level:
User, Sub-admin, Admin, Super-admin
Requirements
- A tiCrypt VM configured as a Slurm submit host (managed by a system administrator)
- Slurm installed and running in the VM image
- Submission permissions on the relevant partition
- Data and scripts staged within the tiCrypt project directory
Overviewโ
tiCrypt integrates with Slurm (Simple Linux Utility for Resource Management) for scheduling compute jobs on secure infrastructure. Jobs are submitted from within a tiCrypt virtual machine, either through the in-browser terminal or an RDP session.
Both sbatch (batch submission) and srun (direct execution, including interactive sessions) are supported.
tiCrypt runs two Slurm instances: a Global Slurm that schedules VM provisioning, and a Local Slurm inside your enclave that you interact with. The commands are identical to what you already know. See Shared Computing to tiCrypt for the full concept mapping.
The script and program names used in the examples below (analysis.sh, run_analysis.py, qc_cohort.R) are illustrative. The workload command may be any program callable from the shell: Python, R, compiled binaries, shell pipelines, Stata, MATLAB, etc.
Verify Slurm Availabilityโ
Before submitting jobs, confirm that Slurm is available on the VM:
sinfo
If this command returns partition and node information, the VM is correctly configured for job submission.
Job Script Structureโ
A job script has two parts: a block of #SBATCH directives followed by the shell commands to execute.
#!/bin/bash
#SBATCH --job-name=my_job
#SBATCH --output=logs/%x_%j.out
#SBATCH --error=logs/%x_%j.err
#SBATCH --time=01:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem=16G
#SBATCH --partition=secure
echo "Running on $(hostname)"
Submit the script:
sbatch myjob.sh
%x expands to the job name and %j to the job ID. The logs/ directory must exist before submission.
Examplesโ
- Minimal Job
- Python
- R Script
- Multi-Step Pipeline
A minimal script that confirms successful submission and execution on a compute node.
#!/bin/bash
#SBATCH --job-name=hello
#SBATCH --output=hello_%j.out
#SBATCH --time=00:05:00
#SBATCH --mem=1G
echo "Hello from $(hostname)"
echo "Job ID: $SLURM_JOB_ID"
date
#!/bin/bash
#SBATCH --job-name=python_job
#SBATCH --output=logs/%x_%j.out
#SBATCH --error=logs/%x_%j.err
#SBATCH --time=02:00:00
#SBATCH --cpus-per-task=4
#SBATCH --mem=16G
#SBATCH --partition=secure
module load python/3.11
source /project/myteam/venv/bin/activate
python /project/myteam/scripts/run_analysis.py \
--input /project/myteam/data/cohort.csv \
--output /project/myteam/results/
#!/bin/bash
#SBATCH --job-name=r_job
#SBATCH --output=logs/%x_%j.out
#SBATCH --error=logs/%x_%j.err
#SBATCH --time=01:30:00
#SBATCH --cpus-per-task=8
#SBATCH --mem=32G
#SBATCH --partition=secure
module load R/4.3
Rscript /project/myteam/scripts/qc_cohort.R \
--in /project/myteam/data/cohort.csv \
--out /project/myteam/results/qc_summary.tsv
This pattern applies when the workload consists of multiple commands executed in sequence.
#!/bin/bash
#SBATCH --job-name=pipeline
#SBATCH --output=logs/%x_%j.out
#SBATCH --error=logs/%x_%j.err
#SBATCH --time=04:00:00
#SBATCH --cpus-per-task=8
#SBATCH --mem=24G
#SBATCH --partition=secure
set -euo pipefail
WORKDIR=/project/myteam/runs/$SLURM_JOB_ID
mkdir -p "$WORKDIR" && cd "$WORKDIR"
bash /project/myteam/scripts/preprocess.sh /project/myteam/data/raw/ ./clean/
python /project/myteam/scripts/transform.py --in ./clean/ --out ./features/
Rscript /project/myteam/scripts/report.R --in ./features/ --out ./report.html
Job Arraysโ
Job arrays are scheduled for a future release. The example below is provided for reference and will not function in current tiCrypt deployments.
Job arrays execute the same script across multiple inputs in parallel.
#!/bin/bash
#SBATCH --job-name=array_job
#SBATCH --array=1-50
#SBATCH --output=logs/%x_%A_%a.out
#SBATCH --error=logs/%x_%A_%a.err
#SBATCH --time=01:00:00
#SBATCH --cpus-per-task=2
#SBATCH --mem=8G
#SBATCH --partition=secure
INPUT=$(sed -n "${SLURM_ARRAY_TASK_ID}p" /project/myteam/inputs.txt)
python /project/myteam/scripts/process_one.py --input "${INPUT}"
%A represents the array job ID and %a the task index. To limit concurrently running tasks, append %N to the array range (e.g., --array=1-50%5 permits at most five tasks at once).
Inline Submission with sbatch --wrapโ
For single-command jobs, the script file can be omitted:
sbatch --wrap="echo \"Date: $(date)\"; echo \"Hostname: \$(hostname)\""
Unescaped expressions like $(date) are evaluated on the submit host before the job is queued. Escaped expressions like \$(hostname) are evaluated on the compute node at execution time.
Combine --wrap with resource directives:
sbatch \
--job-name=quick_test \
--time=00:30:00 \
--cpus-per-task=4 \
--mem=8G \
--partition=secure \
--wrap="python /project/myteam/scripts/sanity_check.py"
Direct Execution with srunโ
srun runs a command directly under Slurm without a script file. It is suited to short commands, interactive sessions, and launching steps from within a job script.
Run a single command on a compute node:
srun --time=00:30:00 --cpus-per-task=4 --mem=8G --partition=secure \
python /project/myteam/scripts/sanity_check.py
Open an interactive shell on a compute node:
srun --pty --time=01:00:00 --cpus-per-task=4 --mem=16G --partition=secure bash
The shell exits and the allocation is released when you type exit.
Use srun inside an sbatch script to launch job steps:
#!/bin/bash
#SBATCH --job-name=stepped_job
#SBATCH --time=02:00:00
#SBATCH --ntasks=4
#SBATCH --mem=16G
#SBATCH --partition=secure
srun --ntasks=1 python /project/myteam/scripts/step_a.py
srun --ntasks=1 python /project/myteam/scripts/step_b.py
GPU Workloadsโ
GPU support is scheduled for Q4 2026. GPU resource requests (--gres=gpu:N) are not available in current tiCrypt deployments. This section will be updated when the feature is released.
Resource Directives Referenceโ
The following flags apply to both sbatch (as #SBATCH directives or command-line options) and srun.
| Directive | Description |
|---|---|
--time | Maximum wall-clock time (HH:MM:SS). Jobs exceeding this limit are terminated. |
--cpus-per-task | Number of CPU cores allocated per task. |
--ntasks | Number of parallel tasks. Set to 1 for non-MPI workloads. |
--mem | Total memory allocation (suffix G or M). Jobs exceeding this limit are terminated. |
--partition | Target partition. Available partitions are determined by the tiCrypt deployment. |
After a job completes, use sacct to review actual resource consumption and refine future requests.
Monitoring and Managing Jobsโ
squeue --me # List your queued and running jobs
scontrol show job <JOBID> # View detailed job information
scancel <JOBID> # Cancel a specific job
scancel --me # Cancel all your jobs
sacct -j <JOBID> --format=JobID,JobName,State,Elapsed,MaxRSS,ExitCode
Workflow Summaryโ
- Compose a job script with
#SBATCHdirectives and the workload command. - Submit the script with
sbatch <script>.sh, or run a command directly withsrun. - Monitor active jobs with
squeue --me. - Review completed jobs with
sacct.
The directive block stays the same across job types. Only the workload command changes.