# How to attach to a running job to run top on compute node

**URL:** <https://ask.cyberinfrastructure.org/t/how-to-attach-to-a-running-job-to-run-top-on-compute-node/912>\
**Category:** Q&A\
**Tags:** slurm, scheduler, researcher\
**Created:** [May 22, 2019, 1:16pm UTC](https://ask.cyberinfrastructure.org/t/how-to-attach-to-a-running-job-to-run-top-on-compute-node/912 "2019-05-22T13:16:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![middelkoopt](https://ask.cyberinfrastructure.org/user_avatar/ask.cyberinfrastructure.org/middelkoopt/32/383_2.png) [@middelkoopt](https://ask.cyberinfrastructure.org/u/middelkoopt)\
**Post date:** [May 22, 2019, 2:24pm UTC](https://ask.cyberinfrastructure.org/t/how-to-attach-to-a-running-job-to-run-top-on-compute-node/912/2 "2019-05-22T14:24:51Z")

</div>

To attach to a running job (job $JOBID)

```auto
srun --pty --jobid $JOBID /bin/bash

```

This will run inside the cgroup (CPU, RAM etc.) of the running job.

If you want to see the processes you can run top directly via

```auto
srun --pty --jobid $JOBID top

```

For jobs with multiple nodes you need first find the node you want to attach to via

```auto
scontrol show job $JOBID |grep NodeList

```

Then use the `-w` switch to specify the node ($NODE)

```auto
srun --pty --jobid $JOBID -w $NODE /bin/bash

```

---

_[View the full topic](https://ask.cyberinfrastructure.org/t/how-to-attach-to-a-running-job-to-run-top-on-compute-node/912)._
