Guide · SLURM · VASP · LAMMPS · 12 min read
How do I submit a job on a SLURM cluster?
Checked against the docs · SLURM documentation 26.05 and VASP wiki · Last checked 12 November 2026 · Spot a mistake? Tell us
Short answer
Write a job script whose #SBATCH lines ask for a partition, nodes, tasks per node and a walltime, followed by the commands that load and run your program; submit it with sbatch from the folder that holds your input files, then follow it with squeue and check how it ended with sacct.
What is SLURM, and why do I need a job script?
A university cluster is many computers shared by many people. You do not run a calculation on it directly. You write a short job script that says what you need (how many machines, how many processes, for how long, in which queue) and what to run, and you hand it to SLURM, the program that shares the cluster out. SLURM puts your job in the queue and starts it when the machines are free.
What do the words mean?
| Word | What it means |
|---|---|
| login node | The computer you reach with ssh. For editing files and submitting jobs, never for running calculations. |
| compute node (or node) | One of the machines that run jobs. Each has a fixed number of cores and amount of memory. |
| core | One processor inside a node. A node commonly has 32 to 128. |
| partition | A queue with its own rules: which nodes, how long a job may run, sometimes who may use it. Common names are debug, short, standard and bigmem, but every cluster names its own. |
| task (or rank) | One copy of your program. VASP and LAMMPS run as many copies working together through MPI (the standard way parallel programs pass data between processes), usually one per core. |
| walltime | The longest your job may run, by the clock on the wall. SLURM stops the job when it is reached. |
| account (or allocation) | Whose time the job is charged to, usually your group's. Some clusters require it. |
| job id | The number SLURM gives your job when you submit it. Every other command uses it. |
| module | A cluster's way of making installed software available: module load vasp adds VASP to your session or job. |
Why does getting it right matter?
Every job goes through this, and each mistake costs something different:
- Walltime too short, and the job is stopped before it finishes, after you have already waited in the queue.
- More than you need, and your group's allocation pays for idle cores, and the job waits longer to start.
- More than the partition allows, and the job is refused or never starts.
- A wrong module or command, and the job fails in its first second: the cheapest way to fail, and the most common on a new cluster.
What goes in a job script?
A minimal script for VASP. The partition, account and module names are placeholders: get the real ones from your cluster's user guide or your research computing team.
#!/bin/bash
#SBATCH --job-name=TiO2-relax
#SBATCH --partition=standard
#SBATCH --account=mygroup
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --time=04:00:00
#SBATCH --output=slurm-%j.out
#SBATCH --error=slurm-%j.err
module load vasp
srun vasp_std#!/bin/bashsays the script is run by the bash shell.- Each
#SBATCHline is a request to SLURM. Bash treats them as comments;sbatchreads them. --job-nameis the name you will see in the queue.--partitionpicks the queue;--accountsays who pays.--nodes=1asks for one whole machine;--ntasks-per-node=32starts 32 copies of the program on it, one per core of a 32-core node.--time=04:00:00is the walltime, in hours, minutes and seconds.--outputand--errorname the log files;%jbecomes the job id. Without them, SLURM writes toslurm-<job id>.out.module load vaspmakes the cluster's VASP available to the job.srun vasp_stdstarts VASP on all the tasks you asked for. Some clusters usempiruninstead, which depending on the MPI library may or may not go through SLURM; your cluster's guide says which to use.
The script runs in the folder you submit it from, so that folder must hold the input files: INCAR, POSCAR, POTCAR and KPOINTS for VASP.
How do I submit it?
To have SLURM check the request without submitting it, use sbatch --test-only job.sh; How do I avoid a failed run from bad settings? lists what else to check before a job goes in the queue.
From the run folder on the login node:
sbatch job.shSLURM answers with the job id, for example Submitted batch job 123456. If it answers with an error instead, the job was not queued; the common errors are in the table near the end.
How do I check the queue?
squeue -u $USERsqueue --me does the same. The output looks like this (an example, not a real queue):
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
123456 standard TiO2-rela jsmith PD 0:00 1 (Priority)
123457 standard Si-static jsmith R 12:41 1 node042The ST column is the state: PD is pending (waiting in the queue), R is running, CG is completing (finishing up).
Why is my job still pending?
For a pending job, the last column of squeue gives the reason:
(Priority): one or more higher-priority jobs are waiting for the same partition. Yours starts in turn.(Resources): the resources it asks for are in use by other jobs. It starts when they free up.- A reason with Limit in its name, such as
QOSMaxJobsPerUserLimit: a cap has been reached; for that one, the number of jobs you may run at once. It starts when one of your other jobs ends. (PartitionTimeLimit): the walltime you asked for is longer than the partition allows. It will not start on its own; see the mistakes table.(ReqNodeNotAvail): a node the job needs is not available: in use, reserved, down or drained (taken out of service).
SLURM's job reason codes page lists the rest.
How do I see how a job ended?
squeue only lists jobs that are waiting or running. For a finished job, ask the accounting record:
sacct -j 123456 --format=JobID,JobName,State,Elapsed,ExitCodeThe State column says how it ended: COMPLETED, FAILED, TIMEOUT (ran out of walltime), CANCELLED or OUT_OF_MEMORY.
COMPLETED only means the job finished with an exit code of zero on all nodes. It does not mean the calculation converged: a relaxation that used up all its ionic steps can still end as COMPLETED. Read the program's own output to know whether the science finished.
How do I cancel a job?
scancel 123456This works whether the job is pending or running. When a job reaches its walltime, SLURM does the same thing for you: each task gets a signal to stop, then a forced kill shortly after.
How many nodes, tasks and hours should I ask for?
Starting points, not rules. Your cluster's limits and your calculation decide.
| Setting | Start with | What it depends on |
|---|---|---|
| First job on a new cluster | A test job: one task, five minutes, the debug or short partition, printing which modules loaded and where the program is | Catches a wrong module, command or path before a real calculation waits in the queue. |
| Nodes | One, for a first calculation on a small cell (tens of atoms) | More nodes help larger cells and more k-points, up to a point; past it, adding nodes slows the job. The documentation gives no rule for when a second node pays off; time a short run on one node and on two and compare. |
| Tasks per node | The node's core count | Some clusters charge for the whole node whether you use it or not; your cluster's documentation says how it charges. Fewer tasks per node can help when a job runs out of memory. |
| Walltime | Your best estimate plus a margin, within the partition's limit | Shorter requests can start sooner: Slurm's backfill scheduler, loaded by default, starts a lower-priority job early when doing so does not delay the expected start of any higher-priority job, and it works that out from the time limits jobs ask for. Too short and the job is stopped. If you leave --time out, the partition's default limit applies. |
| Partition | debug or short for tests; the standard one for production; a large-memory one only if memory is the limit | Larger or longer partitions often wait longer and may cost more. |
For a first estimate of walltime, run a short version and look at how long each step takes. For VASP, OUTCAR records the time each step took; grep LOOP+ OUTCAR lists the timing lines for the ionic steps, but the VASP wiki does not document them, so check that your version prints them. Multiply the time per step by the number of steps you expect and add a margin.
How do I know the job ran the way I asked?
sbatchreturns a job id. If not, read the error; nothing was queued.squeueshows it go fromPDtoR.- The program started with the processes you asked for. VASP prints the number of MPI processes near the top of its output. It should equal nodes × tasks per node: 32 for the script above. In VASP 6 it is the first line of the screen output (your job's output file), for example
running 32 mpi-ranks, with 1 threads/rank, on 1 nodes. Older versions such as 5.4 may word it differently; look for the process count near the top of the output. - It ended the way you think.
sacctsaysCOMPLETED, and the program's own output agrees. A VASP run that finished normally ends itsOUTCARwith a timing summary that beginsGeneral timing and accounting informations for this job(VASP's own spelling). - It asked for about the right amount. Compare
Elapsedinsacctwith the walltime you requested, and addMaxRSS(the most memory any task used) to the--formatlist. Many clusters also offerseff 123456, which summarizes how well the job used its cores and memory.seffis a contributed script that comes in thecontribsfolder of Slurm's source, not one of the documented commands, so it is there only if your cluster installed it.
What usually goes wrong?
| Mistake | What you would see | What to do |
|---|---|---|
| Running the calculation on the login node | Everything on the login node slows down for everyone; an email from the administrators; the process is killed. | Always submit with sbatch. |
| Walltime too short | sacct says TIMEOUT, terminated on reaching the time limit; the error log has a line such as *** JOB 123456 ON node042 CANCELLED AT 2026-10-24T14:02:11 DUE TO TIME LIMIT *** (the node and time are examples). | Continue from where it stopped (for VASP, the CONTCAR) with a longer walltime. |
| Walltime longer than the partition allows | The SLURM docs: the job is left pending, possibly indefinitely, with the reason (PartitionTimeLimit). | Cancel it and ask for less time, or use a partition with a longer limit. |
| More tasks per node than the node has cores | sbatch refuses the job: sbatch: error: Batch job submission failed: Requested node configuration is not available. | Lower --ntasks-per-node to the core count. |
| Missing or wrong account | sbatch refuses the job: sbatch: error: Batch job submission failed: Invalid account or account/partition combination specified. | Add --account with your group's allocation name. |
| Wrong module or program name | vasp_std: command not found in the error log, seconds after the job starts. | Run module avail on the login node and fix the module line or the command. |
| Not enough memory | sacct says OUT_OF_MEMORY; on clusters that limit memory with cgroups, the error log has a line such as Detected 1 oom_kill event in StepId=123456.batch. Some of the step tasks have been OOM Killed. | More nodes, a large-memory partition, fewer tasks per node, or a smaller calculation. |
| Input files missing from the folder | The job ends at once; VASP's output names the file it could not find. | Submit from the folder that holds all four input files. |
| Half-empty nodes | The job runs, but slowly, and the whole node is charged anyway. | Use all of a node's cores unless memory is the limit. |
Try it
Try it: find the problem in the job script
Each job script below has one line that will not do what its author meant. Choose the line you think it is. The answers come from the sbatch manual; the job, module and program names are examples.
Script 1.
#!/bin/bash
#SBATCH --job-name=si-relax
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
module load vasp
#SBATCH --time=02:00:00
srun vasp_stdThe problem is line 6, #SBATCH --time=02:00:00: sbatch stops reading #SBATCH lines at the first line that is not a comment or blank, here module load vasp. The --time line after it is never read, so the job gets the partition's default time limit. Move every #SBATCH line above the first command.
Script 2.
#!/bin/bash
#SBATCH --job-name=si-relax
#SBATCH --output=$HOME/logs/slurm-%j.out
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --time=02:00:00
srun vasp_stdThe problem is line 3, #SBATCH --output=$HOME/logs/slurm-%j.out: SLURM reads #SBATCH lines itself, not through the shell, so shell syntax and variable names are read as literal text: $HOME is not replaced by your home directory. Write the path out in full, or leave --output out: by default the output goes to slurm-%j.out, with %j replaced by the job number.
Script 3.
#!/bin/bash
# a six-hour relaxation
#SBATCH --job-name=si-relax
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --time=6
srun vasp_stdThe problem is line 6, #SBATCH --time=6: A single number is read as minutes, so --time=6 asks for six minutes. The other formats sbatch accepts are minutes:seconds, hours:minutes:seconds, days-hours, days-hours:minutes and days-hours:minutes:seconds. #SBATCH --time=6:00:00.
Set up → Cluster and resources holds the cluster, partition, nodes, ranks per node and walltime, and pre-flight checks them before you submit. Once a job is in the queue, Monitor follows it for you, with only the standard SLURM commands, and says when it will check again; the practice cluster lets you try the whole flow without a real one.