<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.anunna.wur.nl/index.php?action=history&amp;feed=atom&amp;title=Tutorials%2FSlurm-Interactive-Sessions</id>
	<title>Tutorials/Slurm-Interactive-Sessions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.anunna.wur.nl/index.php?action=history&amp;feed=atom&amp;title=Tutorials%2FSlurm-Interactive-Sessions"/>
	<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Tutorials/Slurm-Interactive-Sessions&amp;action=history"/>
	<updated>2026-11-24T05:32:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.anunna.wur.nl/index.php?title=Tutorials/Slurm-Interactive-Sessions&amp;diff=3285&amp;oldid=prev</id>
		<title>Honfi001: Honfi001 moved page Tutorials/slurm-interactive-sessions to Tutorials/Slurm-Interactive-Sessions without leaving a redirect</title>
		<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Tutorials/Slurm-Interactive-Sessions&amp;diff=3285&amp;oldid=prev"/>
		<updated>2026-11-23T10:29:15Z</updated>

		<summary type="html">&lt;p&gt;Honfi001 moved page &lt;a href=&quot;/index.php?title=Tutorials/slurm-interactive-sessions&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Tutorials/slurm-interactive-sessions (page does not exist)&quot;&gt;Tutorials/slurm-interactive-sessions&lt;/a&gt; to &lt;a href=&quot;/Tutorials/Slurm-Interactive-Sessions&quot; title=&quot;Tutorials/Slurm-Interactive-Sessions&quot;&gt;Tutorials/Slurm-Interactive-Sessions&lt;/a&gt; without leaving a redirect&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:29, 23 November 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Honfi001</name></author>
	</entry>
	<entry>
		<id>https://wiki.anunna.wur.nl/index.php?title=Tutorials/Slurm-Interactive-Sessions&amp;diff=3279&amp;oldid=prev</id>
		<title>Honfi001: Created page with &quot;= Interactive Sessions: sinteractive, srun and salloc =  &#039;&#039;Part 1 of the Slurm for beginners series.&#039;&#039;  In this tutorial you will get your first piece of a compute node and type commands on it, just like on your own computer. You will learn three commands:  * &lt;code&gt;sinteractive&lt;/code&gt; — the easy way: open a shell on a compute node. * &lt;code&gt;srun&lt;/code&gt; — run one command on a compute node. * &lt;code&gt;salloc&lt;/code&gt; — reserve resources...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.anunna.wur.nl/index.php?title=Tutorials/Slurm-Interactive-Sessions&amp;diff=3279&amp;oldid=prev"/>
		<updated>2026-11-23T10:05:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Interactive Sessions: sinteractive, srun and salloc =  &amp;#039;&amp;#039;Part 1 of the &lt;a href=&quot;/Tutorials#Slurm_(job_scheduler)&quot; title=&quot;Tutorials&quot;&gt;Slurm for beginners&lt;/a&gt; series.&amp;#039;&amp;#039;  In this tutorial you will get your first piece of a compute node and type commands on it, just like on your own computer. You will learn three commands:  * &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt; — the easy way: open a shell on a compute node. * &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; — run one command on a compute node. * &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; — reserve resources...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Interactive Sessions: sinteractive, srun and salloc =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Part 1 of the [[Tutorials#Slurm (job scheduler)|Slurm for beginners]] series.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will get your first piece of a compute node and type commands on it, just like on your own computer. You will learn three commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt; — the easy way: open a shell on a compute node.&lt;br /&gt;
* &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; — run one command on a compute node.&lt;br /&gt;
* &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; — reserve resources first, then use them.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;You need:&amp;#039;&amp;#039;&amp;#039; an Anunna account, and the ability to log in and type basic Linux commands. If you are unsure about the second part, try the [[Linux Basic/Linux Self Assessment|Linux self-assessment]] first.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Time:&amp;#039;&amp;#039;&amp;#039; about 30 minutes.&lt;br /&gt;
&lt;br /&gt;
== Before you start: login nodes and compute nodes ==&lt;br /&gt;
&lt;br /&gt;
When you log in to Anunna you land on a &amp;#039;&amp;#039;&amp;#039;login node&amp;#039;&amp;#039;&amp;#039;. Think of it as the reception desk of a big laboratory. Everyone walks in through it, so it is a good place to look around, edit files and organise your work. It is &amp;#039;&amp;#039;not&amp;#039;&amp;#039; the place to run experiments. If you do heavy work there, everyone queueing behind you notices.&lt;br /&gt;
&lt;br /&gt;
The real work happens in the lab itself: hundreds of &amp;#039;&amp;#039;&amp;#039;compute nodes&amp;#039;&amp;#039;&amp;#039;. You cannot just walk into one. You ask &amp;#039;&amp;#039;&amp;#039;Slurm&amp;#039;&amp;#039;&amp;#039;, the cluster&amp;#039;s scheduler, and Slurm finds you a free spot and gives you a key. Slurm is the lab manager who books the benches.&lt;br /&gt;
&lt;br /&gt;
There are two ways to ask Slurm for a bench:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! !! Interactive session !! Batch job&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;What it is&amp;#039;&amp;#039;&amp;#039; || You get a shell on a compute node and type commands yourself || You write a script and Slurm runs it for you, unattended&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Good for&amp;#039;&amp;#039;&amp;#039; || Trying things out, testing, installing software, debugging || Real analyses, long runs, many runs&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;You must stay connected?&amp;#039;&amp;#039;&amp;#039; || Yes — close your laptop and the session ends || No — log out and it keeps running&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Covered in&amp;#039;&amp;#039;&amp;#039; || This tutorial || The next one&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Step 1: Your first session with sinteractive ==&lt;br /&gt;
&lt;br /&gt;
Type this on the login node:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sinteractive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
srun: job 19271078 queued and waiting for resources&lt;br /&gt;
srun: job 19271078 has been allocated resources&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then a new prompt. That number is your &amp;#039;&amp;#039;&amp;#039;job ID&amp;#039;&amp;#039;&amp;#039;: every request to Slurm gets one. Nothing else looks different, so check where you are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
hostname&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of a login node you will see the name of a compute node, for example &amp;lt;code&amp;gt;node253&amp;lt;/code&amp;gt;. You are now on a compute node. Everything you type runs there.&lt;br /&gt;
&lt;br /&gt;
When you are done, leave:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt; again and you are back on the login node. Leaving gives your bench back to Slurm so someone else can use it. &amp;#039;&amp;#039;&amp;#039;Always exit when you are finished.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Step 2: Ask for what you need ==&lt;br /&gt;
&lt;br /&gt;
Typing just &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt; gives you a tiny default bench: one CPU core, very little memory and a short time limit. Fine for a peek, too small for real work. You tell Slurm what you need with three options:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Option !! Means !! Example&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt; || How many CPU cores || &amp;lt;code&amp;gt;-c 4&amp;lt;/code&amp;gt; = 4 cores&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;--mem&amp;lt;/code&amp;gt; || How much memory (RAM) || &amp;lt;code&amp;gt;--mem 8G&amp;lt;/code&amp;gt; = 8 gigabytes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;--time&amp;lt;/code&amp;gt; || How long, in minutes || &amp;lt;code&amp;gt;--time 120&amp;lt;/code&amp;gt; = 2 hours&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
So a session with 2 cores, 4 GB of memory and one hour looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sinteractive -c 2 --mem 4G --time 60&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you are in, check that you got what you asked for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nproc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prints &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;: the number of cores that are yours. (Some other tools, like Python&amp;#039;s &amp;lt;code&amp;gt;os.cpu_count()&amp;lt;/code&amp;gt;, report every core on the whole machine instead. &amp;lt;code&amp;gt;nproc&amp;lt;/code&amp;gt; tells the truth about what you were given.)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;How much should I ask for?&amp;#039;&amp;#039;&amp;#039; Start small. Small requests start quickly, and big requests wait longer in the queue. Slurm also holds you to your request: a program that uses more memory than you asked for can be stopped, and when your time runs out the session ends, even mid-command. Ask for a bit more than you think you need, not ten times more.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! If you see... !! It means... !! Try...&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;queued and waiting for resources&amp;lt;/code&amp;gt; for a while || The cluster is busy, or your request is big || Waiting a little, or asking for less&lt;br /&gt;
|-&lt;br /&gt;
| The command gives up after about a minute || &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt; waits at most 60 seconds for a free spot || Asking for less, or trying again later&lt;br /&gt;
|-&lt;br /&gt;
| Your session suddenly closes || Your time ran out, or your connection dropped || A longer &amp;lt;code&amp;gt;--time&amp;lt;/code&amp;gt;; a batch job for long work&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Step 3: srun — run one command on a compute node ==&lt;br /&gt;
&lt;br /&gt;
Here is a secret: &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt; is a small shortcut around another command, &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;. Underneath, it runs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
srun -c 2 --mem 4G --time 60 -I60 -N 1 -n 1 --pty bash -i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That means &amp;quot;start &amp;lt;code&amp;gt;bash&amp;lt;/code&amp;gt; on a compute node and connect my keyboard to it&amp;quot;. You don&amp;#039;t need to remember this. It is just to show that &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; is the real worker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; can also run a &amp;#039;&amp;#039;single command&amp;#039;&amp;#039; on a compute node and bring you straight back:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
srun -c 1 --mem 1G --time 5 hostname&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Slurm finds a spot, runs &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt; there, prints the compute node&amp;#039;s name, and you are back on the login node, all in one go. The options are the same &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--mem&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--time&amp;lt;/code&amp;gt; you already know.&lt;br /&gt;
&lt;br /&gt;
Use this when you want to run &amp;#039;&amp;#039;one thing&amp;#039;&amp;#039; without opening a whole session. Your terminal stays busy until the command finishes, so it suits short tasks.&lt;br /&gt;
&lt;br /&gt;
== Step 4: salloc — book now, connect when you like ==&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt;, the bench is yours only while you are sitting at it. Close the session and it is gone. &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; works more like booking a lab bench for the afternoon: the booking is yours until the time runs out, and you can walk away and come back as often as you like.&lt;br /&gt;
&lt;br /&gt;
It takes two commands: one to book, and one to connect.&lt;br /&gt;
&lt;br /&gt;
=== Book ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
salloc --no-shell -c 2 --mem 4G --time 120&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The options are the same ones you know from &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;--no-shell&amp;lt;/code&amp;gt; means &amp;quot;just make the booking, don&amp;#039;t open anything yet&amp;quot;. Once Slurm has found you a spot, you see:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
salloc: Granted job allocation 12345678&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you are back at your normal prompt on the login node. Nothing is running yet, but those 2 cores and 4 GB are now reserved for you. &amp;#039;&amp;#039;&amp;#039;Write down the job ID&amp;#039;&amp;#039;&amp;#039; (here &amp;lt;code&amp;gt;12345678&amp;lt;/code&amp;gt;). If you forget it, this shows all your jobs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
squeue -u $USER&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Connect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
srun --jobid=12345678 --overlap --pty bash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt; and you will see you are on a compute node, inside your booking. The three options mean:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Option !! Means&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;--jobid=12345678&amp;lt;/code&amp;gt; || Use this booking (put in your own job ID)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;--overlap&amp;lt;/code&amp;gt; || Share the booking with anything else already running in it, so you can connect more than once&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;--pty bash&amp;lt;/code&amp;gt; || Give me a shell I can type in&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
You don&amp;#039;t need &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--mem&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--time&amp;lt;/code&amp;gt; here: you get what you booked.&lt;br /&gt;
&lt;br /&gt;
=== Leave, and come back ===&lt;br /&gt;
&lt;br /&gt;
Type &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; and you are back on the login node. &amp;#039;&amp;#039;&amp;#039;Your booking is still there.&amp;#039;&amp;#039;&amp;#039; Run the same &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; command again to reconnect, after lunch, or from a second terminal at the same time.&lt;br /&gt;
&lt;br /&gt;
If your connection drops, the same rule applies: the booking survives. But anything that was running in your shell is stopped, so you come back to a fresh shell. For a program that must keep running while you are away, use a batch job (the next tutorial).&lt;br /&gt;
&lt;br /&gt;
=== Finish ===&lt;br /&gt;
&lt;br /&gt;
When you are done, cancel the booking:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
scancel 12345678&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Don&amp;#039;t skip this.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; only closes your shell. The booking stays until you cancel it or its time runs out, and until then those cores and that memory are held in your name, unused, while others wait in the queue. Run &amp;lt;code&amp;gt;squeue -u $USER&amp;lt;/code&amp;gt; afterwards. If the job is gone, you are done.&lt;br /&gt;
&lt;br /&gt;
== Which one should I use? ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! I want to... !! Use !! Example&lt;br /&gt;
|-&lt;br /&gt;
| Work on a compute node as if it were my own computer || &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;sinteractive -c 2 --mem 4G --time 60&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Run one quick command on a compute node || &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;srun -c 1 --mem 1G --time 5 hostname&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Book resources for a few hours and connect to them whenever I like || &amp;lt;code&amp;gt;salloc --no-shell&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;srun --jobid&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;salloc --no-shell -c 2 --mem 4G --time 120&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;srun --jobid=12345678 --overlap --pty bash&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;If in doubt, use &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt;.&amp;#039;&amp;#039;&amp;#039; It covers most everyday needs, and it is hard to get wrong.&lt;br /&gt;
&lt;br /&gt;
== Try it yourself ==&lt;br /&gt;
&lt;br /&gt;
# Open a session with 1 core, 2 GB of memory and 30 minutes. Check which node you are on and how many cores you have. Then exit.&lt;br /&gt;
# Without opening a session, use &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; to run &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt; on a compute node.&lt;br /&gt;
# Use &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; to book 1 core and 1 GB for 30 minutes. Connect to it, run &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt;, and exit. Connect again and check you are on the same node. Then cancel the booking and check that it is gone.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Answers:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;sinteractive -c 1 --mem 2G --time 30&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nproc&amp;lt;/code&amp;gt; (which prints &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;), then &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt;.&lt;br /&gt;
# &amp;lt;code&amp;gt;srun -c 1 --mem 1G --time 5 date&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;salloc --no-shell -c 1 --mem 1G --time 30&amp;lt;/code&amp;gt; prints your job ID. Then run &amp;lt;code&amp;gt;srun --jobid=&amp;lt;your job ID&amp;gt; --overlap --pty bash&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt;, and repeat. &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt; shows the same node both times. Finish with &amp;lt;code&amp;gt;scancel &amp;lt;your job ID&amp;gt;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;squeue -u $USER&amp;lt;/code&amp;gt; no longer lists it.&lt;br /&gt;
&lt;br /&gt;
== Cheat sheet ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command !! What it does&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sinteractive -c 2 --mem 4G --time 60&amp;lt;/code&amp;gt; || Open a shell on a compute node&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;srun -c 1 --mem 1G --time 5 my_command&amp;lt;/code&amp;gt; || Run one command on a compute node&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;salloc --no-shell -c 2 --mem 4G --time 120&amp;lt;/code&amp;gt; || Book resources and get a job ID&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;srun --jobid=&amp;lt;ID&amp;gt; --overlap --pty bash&amp;lt;/code&amp;gt; || Connect to your booking (as often as you like)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scancel &amp;lt;ID&amp;gt;&amp;lt;/code&amp;gt; || Cancel a booking (or any job)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt; || Which machine am I on?&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nproc&amp;lt;/code&amp;gt; || How many cores do I have?&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;squeue -u $USER&amp;lt;/code&amp;gt; || What jobs do I have right now?&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; || Leave the session (with &amp;lt;code&amp;gt;sinteractive&amp;lt;/code&amp;gt;, this also gives the resources back)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Next ==&lt;br /&gt;
&lt;br /&gt;
Interactive sessions are for trying things out. When you have something that works and want it to run on its own, even after you log out, you need a &amp;#039;&amp;#039;&amp;#039;batch job&amp;#039;&amp;#039;&amp;#039;. That is the next tutorial in this series.&lt;br /&gt;
&lt;br /&gt;
Want to go deeper into interactive work: cores versus tasks, several nodes, and keeping an allocation open? The &amp;#039;&amp;#039;&amp;#039;Interactive Slurm&amp;#039;&amp;#039;&amp;#039; series starts with [[Tutorials/Slurm-Interactive-Srun|Part 1: srun]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Interactive Jobs]] — reference page with all the details&lt;br /&gt;
* [[Partitions / Queues]] — choosing where your job runs, such as GPU nodes&lt;br /&gt;
* [[Cancelling Jobs]]&lt;br /&gt;
* [[Scheduler Overview (Slurm)]]&lt;/div&gt;</summary>
		<author><name>Honfi001</name></author>
	</entry>
</feed>