> For the complete documentation index, see [llms.txt](https://esciencecu-twiki.sc.chula.ac.th/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://esciencecu-twiki.sc.chula.ac.th/slurm/101-interactive-jobs-with-slurm.md).

# 101: Interactive jobs with Slurm

You can use `salloc` to allocate resources in real-time to run an interactive batch job. Typically this is used to allocate resources and spawn a shell. The shell is then used to execute `srun` commands to launch parallel tasks. Interactive job is useful for tasks including data exploration, development, or (with X11 forwarding) visualization activities. The maximum walltime depends on the [QoS](/slurm/slurm-qos-and-partition.md) you have used.

For worker nodes with CPU and GPU:

```
salloc --qos=cu_hpc --partition=cpugpu
```

For worker nodes with CPU-only:

```
salloc --qos=cu_hpc --partition=cpu
```

After connection, you will get the message like

```
salloc: Granted job allocation 82025
salloc: Waiting for resource configuration
salloc: Nodes cpu-bladeh-01 are ready for job
```

and with `squeue -u your_user_name`, you will see

```
JOBID PARTITION     NAME           USER ST       TIME  NODES NODELIST(REASON)
82025       cpu interact your_user_name  R       1:59      1 cpu-bladeh-01
```

To run, you can use `srun`, e.g.&#x20;

```
[your_user_name@frontend-02 ~]$ srun hostname
cpu-bladeh-01.stg
```

To exit the interactive mode, you can use the command `exit`

```
[your_user_name@frontend-02 ~]$ exit
exit
salloc: Relinquishing job allocation 82025
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://esciencecu-twiki.sc.chula.ac.th/slurm/101-interactive-jobs-with-slurm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
