<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://giwiki.gi.ucsc.edu/index.php?action=history&amp;feed=atom&amp;title=Convenient_Slurm_Commands</id>
	<title>Convenient Slurm Commands - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://giwiki.gi.ucsc.edu/index.php?action=history&amp;feed=atom&amp;title=Convenient_Slurm_Commands"/>
	<link rel="alternate" type="text/html" href="http://giwiki.gi.ucsc.edu/index.php?title=Convenient_Slurm_Commands&amp;action=history"/>
	<updated>2026-06-30T02:39:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>http://giwiki.gi.ucsc.edu/index.php?title=Convenient_Slurm_Commands&amp;diff=519&amp;oldid=prev</id>
		<title>Weiler: Created page with &quot;__TOC__ ==General commands==  Get documentation on a command:  man &lt;command&gt;  Try the following commands:  man sbatch  man squeue  man scancel  ==Submitting Jobs==  The following example script specifies a partition, time limit, memory allocation and number of cores. All your scripts should specify values for these four parameters. You can also set additional parameters as shown, such as jobname and output file. For This script performs a simple task — it generates of...&quot;</title>
		<link rel="alternate" type="text/html" href="http://giwiki.gi.ucsc.edu/index.php?title=Convenient_Slurm_Commands&amp;diff=519&amp;oldid=prev"/>
		<updated>2024-09-28T16:40:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__TOC__ ==General commands==  Get documentation on a command:  man &amp;lt;command&amp;gt;  Try the following commands:  man sbatch  man squeue  man scancel  ==Submitting Jobs==  The following example script specifies a partition, time limit, memory allocation and number of cores. All your scripts should specify values for these four parameters. You can also set additional parameters as shown, such as jobname and output file. For This script performs a simple task — it generates of...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__TOC__&lt;br /&gt;
==General commands==&lt;br /&gt;
&lt;br /&gt;
Get documentation on a command:&lt;br /&gt;
 man &amp;lt;command&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Try the following commands:&lt;br /&gt;
 man sbatch&lt;br /&gt;
 man squeue&lt;br /&gt;
 man scancel&lt;br /&gt;
&lt;br /&gt;
==Submitting Jobs==&lt;br /&gt;
&lt;br /&gt;
The following example script specifies a partition, time limit, memory allocation and number of cores. All your scripts should specify values for these four parameters. You can also set additional parameters as shown, such as jobname and output file. For This script performs a simple task — it generates of file of random numbers and then sorts it. A detailed explanation the script is available here.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH -p shared # partition (queue)&lt;br /&gt;
 #SBATCH -c 1 # number of cores&lt;br /&gt;
 #SBATCH --mem 100 # memory pool for all cores&lt;br /&gt;
 #SBATCH -t 0-2:00 # time (D-HH:MM)&lt;br /&gt;
 #SBATCH -o slurm.%N.%j.out # STDOUT&lt;br /&gt;
 #SBATCH -e slurm.%N.%j.err # STDERR&lt;br /&gt;
 for i in {1..100000}; do&lt;br /&gt;
 echo $RANDOM &amp;gt;&amp;gt; SomeRandomNumbers.txt&lt;br /&gt;
 donesort SomeRandomNumbers.txt&lt;br /&gt;
&lt;br /&gt;
Now you can submit your job with the command:&lt;br /&gt;
 sbatch myscript.sh&lt;br /&gt;
If you want to test your job and find out when your job is estimated to run use (note this does not actually submit the job):&lt;br /&gt;
 sbatch --test-only myscript.sh&lt;br /&gt;
&lt;br /&gt;
==Information On Jobs==&lt;br /&gt;
&lt;br /&gt;
List all current jobs for a user:&lt;br /&gt;
 squeue -u &amp;lt;username&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all running jobs for a user:&lt;br /&gt;
 squeue -u &amp;lt;username&amp;gt; -t RUNNING&lt;br /&gt;
&lt;br /&gt;
List all pending jobs for a user:&lt;br /&gt;
 squeue -u &amp;lt;username&amp;gt; -t PENDING&lt;br /&gt;
&lt;br /&gt;
List priority order of jobs for the current user (you) in a given partition:&lt;br /&gt;
 showq-slurm -o -u -q &amp;lt;partition&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List jobs run by the current user since a certain date:&lt;br /&gt;
 sacct --starttime &amp;lt;YYYY-MM-DD&amp;gt; &lt;br /&gt;
&lt;br /&gt;
List jobs run by a user during an interval marked by a start, -S, and an end, -E, date along with the information on the job id, the allocated node, partition, number of allocated CPUs, state of the job, and the start time of the job:&lt;br /&gt;
&lt;br /&gt;
 sacct -S &amp;lt;YYYY-MM-DD&amp;gt; -E &amp;lt;YYYY-MM-DD&amp;gt; -u &amp;lt;username&amp;gt; --format=JobID,nodelist,Partition,AllocCPUs,State,start&lt;br /&gt;
&lt;br /&gt;
If the end date is left out, then the sacct command will list the jobs starting from the start date until now.&lt;br /&gt;
&lt;br /&gt;
List detailed information for a currently running job (useful for troubleshooting):&lt;br /&gt;
 scontrol show jobid -dd &amp;lt;jobid&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List status info for a currently running job:&lt;br /&gt;
 sstat --format=AveCPU,AvePages,AveRSS,AveVMSize,JobID -j &amp;lt;jobid&amp;gt; --allsteps&lt;br /&gt;
&lt;br /&gt;
To view the command line argument at the time of submission of a job:&lt;br /&gt;
 sacct -j &amp;lt;jobid&amp;gt; -o submitline -P&lt;br /&gt;
&lt;br /&gt;
To see the batch script of a submitted job:&lt;br /&gt;
 sacct -j &amp;lt;jobid&amp;gt; --batch&lt;br /&gt;
&lt;br /&gt;
Once your job has completed, you can get additional information that was not available during the run. This includes run time, memory used, etc.&lt;br /&gt;
&lt;br /&gt;
To get statistics on both completed jobs and currently running jobs by jobID:&lt;br /&gt;
 sacct -j &amp;lt;jobid&amp;gt; --format=JobID,JobName,MaxRSS,Elapsed,nodelist -X&lt;br /&gt;
&lt;br /&gt;
To view the same information for all jobs of a user:&lt;br /&gt;
 sacct -u &amp;lt;username&amp;gt; --format=JobID,JobName,MaxRSS,Elapsed&lt;br /&gt;
&lt;br /&gt;
==Controlling jobs==&lt;br /&gt;
&lt;br /&gt;
To cancel one job:&lt;br /&gt;
 scancel &amp;lt;jobid&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To cancel all the jobs for a user:&lt;br /&gt;
 scancel -u &amp;lt;username&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To cancel all the pending jobs for a user:&lt;br /&gt;
 scancel -t PENDING -u &amp;lt;username&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To cancel one or more jobs by name:&lt;br /&gt;
 scancel --name myJobName&lt;br /&gt;
&lt;br /&gt;
To hold a particular job from being scheduled:&lt;br /&gt;
 scontrol hold &amp;lt;jobid&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To release a particular job to be scheduled:&lt;br /&gt;
 scontrol release &amp;lt;jobid&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To requeue (cancel and rerun) a particular job:&lt;br /&gt;
 scontrol requeue &amp;lt;jobid&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Job Arrays and Useful Commands==&lt;br /&gt;
&lt;br /&gt;
As shown in the commands above, its easy to refer to one job by its Job ID, or to all your jobs via your username. What if you want to refer to a subset of your jobs? The answer is to submit your job set as a job array. Then you can use the job array ID to refer to the set when running SLURM commands. &lt;br /&gt;
&lt;br /&gt;
SLURM job arrays&lt;br /&gt;
&lt;br /&gt;
To cancel an indexed job in a job array:&lt;br /&gt;
 scancel &amp;lt;jobid&amp;gt;_&amp;lt;index&amp;gt;&lt;br /&gt;
e.g.&lt;br /&gt;
 scancel 1234_4&lt;br /&gt;
To find the original submit time for your job array&lt;br /&gt;
 sacct -j 32532756 -o submit -X --noheader | uniq&lt;br /&gt;
&lt;br /&gt;
==Advanced (but useful!) Commands==&lt;br /&gt;
&lt;br /&gt;
The following commands work for individual jobs and for job arrays, and allow easy manipulation of large numbers of jobs. You can combine these commands with the parameters shown above to provide great flexibility and precision in job control. (Note that all of these commands are entered on one line)&lt;br /&gt;
&lt;br /&gt;
Suspend all running jobs for a user (takes into account job arrays):&lt;br /&gt;
 squeue -ho %A -t R | xargs -n 1 scontrol suspend&lt;br /&gt;
&lt;br /&gt;
Resume all suspended jobs for a user:&lt;br /&gt;
 squeue -o &amp;quot;%.18A %.18t&amp;quot; -u &amp;lt;username&amp;gt; | awk '{if ($2 ==&amp;quot;S&amp;quot;){print $1}}' | xargs -n 1 scontrol resume&lt;br /&gt;
&lt;br /&gt;
After resuming, check if any are still suspended:&lt;br /&gt;
 squeue -ho %A -u $USER -t S | wc -l&lt;/div&gt;</summary>
		<author><name>Weiler</name></author>
	</entry>
</feed>