sbatch Command Examples in Linux

sbatch is a command-line utility used to submit a batch job to the SLURM scheduler on a Linux-based high-performance computing (HPC) cluster. SLURM is a workload manager and job scheduler that manages and allocates resources on a cluster, such as CPU time, memory, and network connectivity, for users to run their jobs.

When submitting a batch job with sbatch, you specify a script file that contains the commands and settings necessary to run your job. The script file can include instructions for tasks such as compiling and executing programs, specifying resource requirements for the job, and defining any necessary environment variables or module dependencies.

sbatch also allows you to specify various options for your job, such as the number of CPU cores, memory requirements, maximum run time, and queue placement. You can use the command-line options to specify these requirements or include them in the script file using special comment lines that begin with “#SBATCH”.

After submitting a job with sbatch, you can use other SLURM commands to check the status of the job, monitor its progress, and retrieve output files. For example, the squeue command can be used to list all jobs in the queue, while the scontrol show job command can provide detailed information about a specific job.

sbatch Command Examples

1. Submit a batch job:

# sbatch path/to/job.sh

2. Submit a batch job with a custom name:

# sbatch --job-name=myjob path/to/job.sh

3. Submit a batch job with a time limit of 30 minutes:

# sbatch --time=00:30:00 path/to/job.sh

4. Submit a job and request multiple nodes:

# sbatch --nodes=3 path/to/job.sh

Summary

Overall, sbatch is a powerful tool for submitting batch jobs to an HPC cluster and managing the resources used by those jobs. It can help automate repetitive or resource-intensive tasks, allowing users to focus on their research or other work. More information on sbatch and its various options and parameters can be found in the manual page provided by the command, or in the online documentation available at the link provided.

Related Post