Skip to main content

Slurm usage


sinfo View status information for partitions and nodes

sbatch Submit a job (**For detailed operations, refer to Section 3.3 below**)

squeue View the status of submitted jobs

scancel Cancel a submitted job

scontrol i#i View job-related information

1. sinfo: View node status

# sinfo Query the idle status of nodes in each partition

$ sinfo
PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
test up infinite 1 idle n00001

# Node status STATE includes the following types:
# idle Status is idle
# mix Status indicates some core resources are available on the node
# alloc Status indicates the node is fully occupied
# drain Node failure
# down Node is offline

2. sbatch: Submit job

# sbatch is used to submit jobs to the job scheduling system. For detailed operations, refer to the Job Submission and Execution section below.

$ sbatch jobscript.slurm

# After submitting a script with sbatch, if the job runs normally, a job ID is returned. The job starts running once the required resources are available.

3. squeue: View job information

# squeue View the queue status of submitted jobs

$ squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)

# squeue output includes: Job ID, Partition, Job Name, User, Job Status, Runtime, Number of Nodes, Running Nodes (or queue reason if pending).

# Job status ST includes: R (Running), PD (Pending), CG (Completing), CD (Completed).

4. scancel: Cancel job

# scancel Cancel a submitted job in the queue

# Obtain the job ID to cancel using the squeue command. To cancel a specific job ID, for example, job ID 111, use the following command:
scancel 111

# To cancel all jobs for the currently logged-in account
scancel -u `whoami`

5. scontrol: View and modify job parameters

# Display detailed information for all jobs of this user
$ scontrol show job

# To view detailed information for a specific job, append the job ID to the command. For example, for job ID 111:
$ scontrol show job 123

# Display detailed information for all nodes (not recommended, as this will print extensive information)
$ scontrol show node

# Display detailed information for a specific node (recommended). Obtain the node assigned to the job using squeue, then use the following command to get CPU and memory information for that node. For example, for node n00001:
$ scontrol show node n00001

6. sacct: View job information

sacct -o start,end,nodelist -j jobid
#### View the runtime of a specific job ID using the node ID
sacct -S 2024-04-15 -E 2024-04-22 -o CPUTimeRAW |awk '{s+=$1} END{print s}'
## Manually check machine hours for a specific time point. Divide the total by 3600 to get core-hours. -S specifies the start time, -E specifies the end time.